Gaming
 

Cosmos Patcher Plugin API

From WoWWiki

Cosmos Patcher plugins must end in ".cpl". The plugins are written in RBScript which has most of the language features of Realbasic including math and string functions but the script is sandboxed thus allowing the app to expose only what it wishes to. For more information see the RBScript wiki.


The format of the plugin is as follows:
[Plugin Name]
[Plugin Type]
[Uses Config]
[Plugin Script]


The first two items above are single lines followed by the script which is as many lines as need to implement the plugin.

The plugin Types are "Patcher" and "Uploader". The upload type is for plugins that collect information from the game like the thottbot addon. The uploader plugins will only be provided access to the SavedVariables.lua and the other files under the SavedVariables folder. The Patcher plugin type provides the checking and downloading of addons. The Patcher addon is only provided with items contained within the interface folder.

The Patcher plugin will need to implement the following functions:

'Functions dealing with prefs
Sub PI_GenerateDefaults()
Sub PI_PrefsLoaded()
Sub PI_SetupConfigureWin()

'Function dealing with downloading:
Sub PI_FileListStart()
Sub PI_FileListConnected()
Sub PI_FileListDataAvailable()
Sub PI_FileListError()
Sub PI_FileFetchStartFile()
Sub PI_FileFetchConnected()
Sub PI_FileFetchDataAvailable()
Sub PI_FileFetchError()

'Functions dealing with uploading
Sub PI_UploadStart()
Sub PI_UploadConnected()
Sub PI_UploadDataAvailable()
Sub PI_UploadSendComplete()
Sub PI_UploadError()

The Patcher plugin will have access to the following functions and variables

'Functions and variables when PI_SetupConfigure is called
Sub AddCheckBox(Name as string, X as integer, Y as integer, Height as Integer, Width as integer, Checked as Boolean, text as string)
Sub AddRadioButton(Name as string, X as integer, Y as integer, Height as Integer, Width as integer, Group as Integer, Selected as Boolean, text as string)
Sub AddPopUpMenu(Name as string, X as integer, Y as integer, Height as Integer, Width as integer, Title as string)
Sub AddPopUpItem(PopName as string, Item as string, Val as string, Selected as Boolean)
Sub AddEditBox(Name as string, X as integer, Y as integer, Height as Integer, Width as integer, Password as Boolean, text as string)
Sub AddStaticText(Name as string, X as integer, Y as integer, Height as Integer, Width as integer, text as string)

Working Interface Draft:
Structure of the AddonFile
AddonFile {

 Name as string
 md5Sum as string
 Size as integer
 CompressedSize as integer
 Compressed as string
 Uncompressed as string

}

Contents

Preference Interface

Events Functions implemented by the plugin

  • Sub PI_GenerateDefaults()
  • Sub PI_PrefsLoaded()
  • Sub PI_SetupConfigureWin()

Functions provided to the plugin

  • Function GetPrefConfigCount() as integer
  • Function GetPrefAddonCount() as integer
  • Function GetPrefDistroCount() as integer
  • Function GetPrefAddonFileCount(AddonName as string) as integer
  • Function GetPrefAddonFileCount(AddonIdx as integer) as integer
  • Function GetPrefAddonFile(AddonIdx as integer, FileName as string) as AddonFile
  • Function GetPrefAddonFile(AddonIdx as integer, FileIdx as integer) as AddonFile
  • Function GetPrefConfig(prefName as string, prefDefault as string)
  • Sub GetPrefDistro(DistroIdx as integer, byref distroName, byref distroValue)
  • Function GetPrefAddonName(AddonIdx as integer) as string
  • Sub SetPrefConfig(prefName as string, prefValue as string)
  • Sub SetPrefAddonFile(AddonName as string, AddFile as AddonFile)
  • Sub SetPrefDistro(distroName as string, distroValue as string)
  • Sub ClearPrefConfigs()
  • Sub ClearPrefAddons()
  • Sub ClearPrefAddonFiles(AddonName as string)
  • Sub ClearPrefDistros()
  • Sub RemoveAddon(AddonName as string)
  • Sub RemoveAddonFile(FileName as string)
  • Sub RemovePrefConfig(ConfigName as string)
  • Sub RemovePrefDistro(DistroName as string)



Saving variables between script runs

Functions provided to the plugin

  • Sub SetRunVariable(VarName as string, VarVar as variant)
  • Function GetRunVariable(VarName as string) as variant



Download script events and functions

Events Functions implemented by the plugin

  • Sub PI_FileListStart()
  • Sub PI_FileListConnected()
  • Sub PI_FileListDataAvailable()
  • Sub PI_FileListError()
  • Sub PI_FileFetchStartFile()
  • Sub PI_FileFetchConnected()
  • Sub PI_FileFetchDataAvailable()
  • Sub PI_FileFetchError()

Functions provided to the plugin

  • Sub Connect(Server as string, Port as string)
  • Sub SetFinishedFlag()
  • Sub AddErrorMessage(Message as string)
  • Function GetData(byref Size as integer) As string
  • Sub SendData(Data as string, Size as integer)
  • Sub AddAddonFile(AddonName as string, AddFile as AddonFile)
  • Function GetAddonFile(AddonName as string FileName as string) As AddonFile
  • Function ComputeMd5Sum(FileContents as string) As String
  • Sub GetSavedVarFile(AddonName as string, byref FileData as string)
  • Sub SetSavedVarFile(AddonName as string, FileData as string)
  • Sub SetMissingFilesAreRemovedFlag()
  • Sub ClearMissingFileAreRemovedFlag()
  • Function UnZipFile(ZippedFile as string, UnZippedSize as integer, byref Error as integer) as string



Upload script events and functions

Events Functions implemented by the plugin

  • Sub PI_UploadStart()
  • Sub PI_UploadConnected()
  • Sub PI_UploadDataAvailable()
  • Sub PI_UploadSendComplete()
  • Sub PI_UploadError()

Functions provided to the plugin

  • Sub Connect(Server as string, Port as string)
  • Sub SetFinishedFlag()
  • Sub AddErrorMessage(Message as string)
  • Function GetData(byref Size as integer) As string
  • Sub SendData(Data as string, Size as integer)
  • Sub GetSavedVarFile(AddonName as string, byref FileData as string)
  • Sub SetSavedVarFile(AddonName as string, FileData as string)
  • Function ZipFile(FileContents as string, byref Error as integer) as string