Skip to content

Commit

Permalink
Merge branch 'release/1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktekinay committed Jul 21, 2015
2 parents 7e5ee16 + ac1b03d commit df85cb9
Show file tree
Hide file tree
Showing 12 changed files with 596 additions and 354 deletions.
2 changes: 2 additions & 0 deletions Kaju Admin App/App.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,7 @@ Inherits Application
#tag EndConstant


#tag ViewBehavior
#tag EndViewBehavior
End Class
#tag EndClass
7 changes: 4 additions & 3 deletions Kaju Admin App/Kaju Admin.xojo_project
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ Class=CheckBoxChanger;Controls/CheckBoxChanger.xojo_code;&h5115CD40;&hE8B14E5;fa
Class=FolderItemAlias;Other Classes/FolderItemAlias.xojo_code;&h53EF1AE5;&h6AF5D169;false
Class=HTTPSSocket;../Kaju Classes/Kaju/HTTPSSocket.xojo_code;&h5ACDFAEB;&h11400316;false
Plist=Info;Custom Plist/Info.plist;&h7393D7FF;&h74C1A7FF;false
Class=KajuFile;KajuFile.xojo_code;&h1A7FF7FF;&h0;false
AppMenuBar=MainMenuBar
MajorVersion=1
MinorVersion=5
SubVersion=2
SubVersion=3
NonRelease=0
Release=3
InfoVersion=Kaju Admin
LongVersion=v.1.5.2
ShortVersion=1.5.2
LongVersion=v.1.5.3
ShortVersion=1.5.3
WinCompanyName=MacTechnologies Consulting
WinInternalName=
WinProductName=
Expand Down
246 changes: 246 additions & 0 deletions Kaju Admin App/KajuFile.xojo_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
#tag Class
Protected Class KajuFile
#tag Method, Flags = &h21
Private Sub CreateRSAKeys()
if mPrivateKey = "" then
if not Crypto.RSAGenerateKeyPair( 2048, mPrivateKey, mPublicKey ) then
raise new Kaju.KajuException( "Could not generate RSA keys", CurrentMethodName )
end if
end if

return
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Function ExportFilename() As String
return mExportFilename
End Function
#tag EndMethod

#tag Method, Flags = &h0
Sub ExportTo(f As FolderItem)
dim data as JSONItem = DataToJSON
data.Compact = false
data.EscapeSlashes = false

//
// Perform $VERSION$ substitutions
//
dim keys() as string = Array( Kaju.UpdateInformation.kMacBinaryName, Kaju.UpdateInformation.kWindowsBinaryName, _
Kaju.UpdateInformation.kLinuxBinaryName )

dim lastVersionIndex as integer = data.Count - 1
for versionIndex as integer = 0 to lastVersionIndex
dim thisVersionData as JSONItem = data( versionIndex )
dim thisVersion as string = thisVersionData.Value( kVersionName )
for each binaryKey as string in keys
if thisVersionData.HasName( binaryKey ) then
dim binaryData as JSONItem = thisVersionData.Value( binaryKey )
dim url as string = binaryData.Value( Kaju.BinaryInformation.kKeyURL )
url = InsertVersion( url, thisVersion )
binaryData.Value( Kaju.BinaryInformation.kKeyURL ) = url
end if
next
next

dim dataString as string = data.ToString

dim sig as string = Crypto.RSASign( dataString, PrivateKey )
sig = EncodeHex( sig )

dataString = Kaju.kUpdatePacketMarker + sig + EndOfLine.UNIX + dataString

dim tos as TextOutputStream = TextOutputStream.Create( f )
tos.Write dataString
tos = nil

mExportFilename = f.Name

End Sub
#tag EndMethod

#tag Method, Flags = &h0
Shared Function InsertVersion(originalURL As String, version As String) As String
return originalURL.ReplaceAllB( "$VERSION$", version )
End Function
#tag EndMethod

#tag Method, Flags = &h0
Sub Load(f As FolderItem)
dim tis as TextInputStream = TextInputStream.Open( f )
tis.Encoding = Encodings.UTF8
dim contents as string = tis.ReadAll()
tis.Close
tis = nil

dim root as new JSONItem( contents )

mPrivateKey = root.Lookup( kPrivateKeyName, "" )
mPublicKey = root.Lookup( kPublicKeyName, "" )

//
// Going to use the orinal default here in case this is an old file
//
mExportFilename = root.Lookup( kExportFilenameName, "UpdateInformation.html" )

redim KajuData( -1 )

dim data as JSONItem = root.Lookup( kDataName, nil )
if data isa JSONItem then
dim lastIndex as integer = data.Count - 1
for i as integer = 0 to lastIndex
dim update as new Kaju.UpdateInformation( data( i ) )
KajuData.Append update
next
end if
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Function PrivateKey() As String
CreateRSAKeys
return mPrivateKey
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function PublicKey() As String
CreateRSAKeys
return mPublicKey
End Function
#tag EndMethod

#tag Method, Flags = &h0
Sub SaveTo(f As FolderItem)
dim master as JSONItem = ToJSON
master.Compact = false

dim toSave as string = master.ToString

dim bs as BinaryStream = BinaryStream.Create( f, true )
bs.Write( toSave )
bs.Close

dim tis as TextInputStream = TextInputStream.Open( f )
dim compare as string = tis.ReadAll
tis.Close

dim jCompare as new JSONItem( compare )
jCompare.Compact = master.Compact

if not StrComp( toSave, jCompare.ToString, 0 ) = 0 then
raise new IOException
end if

End Sub
#tag EndMethod


#tag ComputedProperty, Flags = &h0
#tag Getter
Get
dim data as new JSONItem( "[]" )
for each update as Kaju.UpdateInformation in KajuData
data.Append update.ToJSON
next

return data
End Get
#tag EndGetter
DataToJSON As JSONItem
#tag EndComputedProperty

#tag Property, Flags = &h0
KajuData() As Kaju.UpdateInformation
#tag EndProperty

#tag Property, Flags = &h0
mExportFilename As String = "UpdateInformation.json"
#tag EndProperty

#tag Property, Flags = &h21
Private mPrivateKey As String
#tag EndProperty

#tag Property, Flags = &h21
Private mPublicKey As String
#tag EndProperty

#tag ComputedProperty, Flags = &h0
#tag Getter
Get
dim root as new JSONItem
root.Value( kPrivateKeyName ) = PrivateKey
root.Value( kPublicKeyName ) = PublicKey
root.Value( kExportFilenameName ) = ExportFilename

dim data as JSONItem = DataToJSON
root.Value( kDataName ) = data

return root
End Get
#tag EndGetter
ToJSON As JSONItem
#tag EndComputedProperty


#tag Constant, Name = kDataName, Type = String, Dynamic = False, Default = \"KajuData", Scope = Private
#tag EndConstant

#tag Constant, Name = kExportFilenameName, Type = String, Dynamic = False, Default = \"ExportFilename", Scope = Private
#tag EndConstant

#tag Constant, Name = kPrivateKeyName, Type = String, Dynamic = False, Default = \"PrivateKey", Scope = Private
#tag EndConstant

#tag Constant, Name = kPublicKeyName, Type = String, Dynamic = False, Default = \"PublicKey", Scope = Private
#tag EndConstant

#tag Constant, Name = kVersionName, Type = String, Dynamic = False, Default = \"Version", Scope = Public
#tag EndConstant


#tag ViewBehavior
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="mExportFilename"
Group="Behavior"
InitialValue="UpdateInformation.json"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
Loading

0 comments on commit df85cb9

Please sign in to comment.