Jukebox Synchronizer Object Model

 

Introduction

JBSynch exposes an object model as an ActiveX out-proc server. The only directly creatable object is JBSynch.Application. Use the CreateNewJob member to return an object (CJBSynchApp) allowing you to automate all of JBSynch's features.

 

At the heart of JBSynch are its “config files.” Users create new config files via File|New. Each config stores information like folders to be excluded, folder information, and pointers to the library snapshots (which are given unique names to allow for multiple configs to be able to synchronize the same folders). After a JBSynch object is returned from CreateNewJob, a new config file must either be opened or created (CreateDefaultConfig, OpenConfig).

Conventions

This document uses C style conventions for describing JBSynch’s objects. String GetSetting(String Key) is the equivalent of VB’s Function GetSetting(Key as String) as String. Void denotes no value is passed (or in some cases returned- equivalent of a VB Sub).

Application Object

Members

String GetSetting(String Key)

                Returns a setting from JBSynch’s main settings file (jbsynch.ini).

Void WriteSetting(String Key, String Value)

                Writes a setting to JBSynch’s main settings file (jbsynch.ini).

CJBSynchApp CreateNewJob(Void)

                Returns a CJBSynchApp object. You must keep a reference to the object returned by this function alive. When all references to the object are released the object is destroyed. Each call to CreateNewJob returns a new CJBSynchApp object.

 

CJBSynchApp Object

Members

 

Config File

String AddInGetConfigValue(IJBSynchAddIn Object, String Key) / Void AddInWriteConfigValue(IJBSynchAddIn Object, String Key, String Value)

                Same as GetConfigValue/WriteConfigValue but stores values specific to an Add-In. The values are completely defined by the Add-In developer. When the Add-In is removed by the user the values are destroyed.

Void CreateDefaultConfig(String File)

                Creates a new JBSynch config file. The file is initialized with default settings. If File already exists some of its settings are reset to default values.

String GetConfigFileName(Void)

                Retrieve the currently opened config’s filename and path. Returns an empty string if OpenConfig has not been called.

String GetConfigValue(String Key) / Void WriteConfigValue(String Key, String Value)

                Retrieve or set a value from the currently opened config file (See ‘Config File Settings’ below for more info).

Void OpenConfig(String File)

                Opens a JBSynch config file. If the method is not successful an error is raised.

 

Synchronization

Boolean Property AllowActions(JBSynch_ActionsEnum)

                Specifies what actions will be carried out by the StartJob method. Equivalent of calling GetConfigValue/WriteConfigValue and specifying the ‘Action’ key (for example, GetConfigValue(“Action1”)

Boolean AreDirsValid(Void)

                Dir1 (Source) or Dir2 (Dest) exist and are available. Use it before calling StartJob. If not, and the dirs are not available, a runtime error occurs.

Boolean Property RECYCLE

                Determines whether deletes are carried out via the Windows recycle bin. This value is initialized to a value in the config file when a config file is opened (GetConfigValue(“RecycleKill”)) but can be modified at any time without writing anything to the config file.

Void ResetLibraries(Void)

                Resets the library snapshots. The equivalent of the user selecting ‘File|Reset Libraries’ except no prompt is shown to the user.

Void StartJob(Void)

                Starts the job. Actions allowed via the AllowedActions property are run. Also you can use WriteConfigValue method to customize what occurs during StartJob.

 

User Interface Windows And Actions

Void AddInWorkStatus(Long Current, Long Total, String Message)

                Allows an Add-In to keep the user abreast of its progress. If Current=-1 then a “Please Wait…” message is displayed, otherwise a progressbar is displayed.

Void ShowAddInManager(Void)

                Displays the Add-In Manager window to the user.

Void ShowHelp(Void)

                Displays the JBSynch help file to the user.

Void ShowHomePage(Void)

                Opens the system’s default web browser and navigates to JBSynch’s home page on the web.

Void ShowMainUI(Integer Modal)

                Displays the main JBSynch wizard window to the user.

Void ShowManageConfigOp(JBSynch_ConfigOpsEnum)

                Presents the user with various config management options like File|Open, File|New, etc. Also prompts to delete the currently opened config, etc.

Void ShowTool(JBSynch_ToolsEnum)

                Launches JBSynch’s various tools (in the Tools menu) like the Playlist Builder and Log Viewer.

Void ShowUI(JBSynch_UIEnum)

                Displays JBSynch’s various windows (other than the main UI window) like the Settings window, which allows the user to configure the currently opened config file, etc.

Events

AddInsChanged()

                Fires whenever an Add-In is loaded or unloaded.
AppExit()
                Fires when JBSynch is being unloaded.

BeforeActionStart(String ActionText)

                Fires before an action is about to take place. Actions include Synchronization, Creating Shuffled Playlists, etc.

BeforeLogShow()

                Fires at the end of the job but before the log is shown to the user.

ConfigOpened()

                Fires when a config file has successfully been opened. Both OpenConfig, used to programmatically open a config file, and ShowManageConfigOp, used to allow the user to open a config file, trigger this event.

JobEnded()

                Fires when StartJob has ended.

JobStarted()

                Fires when StartJob has been called.

WorkStatus(Long Current, Long Total, String Message)

                Fires various times during a job and relays status. The Current/Total values contain progress information.

 

Config File Settings

dir1=C:\Temp\AJBTest – Source folder

dir2=G:\Store\JBSynch Test – Dest folder

CopyToDir2=-1 – Copy files to Dest that have been added or modified in Source

CopyToDir1=-1 – Copy files to Source that have been added or modified in Dest

DeleteFromDir2=-1 – Delete files from Dest that have been deleted in Source

DeleteFromDir1=-1 – Delete files from Source that have been deleted in Dest

DetectRenamedFolders=-1 – Detect renamed folders

ConfirmSynch=-1 – Prompt the user to confirm synchronization actions

NewPlsPrefix=New – Name used when generating New Files Playlists

NewPlsMaxEntries=200 – Max entries per New Files Playlists. If entries exceed the playlist is broken up into multiple files.

ShuffledPlsPrefix=All - Name used when generating Shuffled All Playlists.

ShuffledPlsMaxEntries=200 – Max entries per All Files Playlists. If entries exceed the playlist is broken up into multiple files.

RecycleKill=-1 – Use Windows Recycle bin when deleting files (works globally across all JBSynch features).

PlsSubfolder= - Subfolder of Source/Dest to place all JBSynch generated playlists.

action0= 1 – Equivalent of AllowActions Enum

action1= 1

action2= 1

action3= 1

action4= 1

action5= 1

action6= 1

ExcludeFolders= - Excluded folders stored as a single comma delimited string

NewPlsExclude=

ShuffledPlsExclude=

ExcludeTypes=temp,tmp, - filetypes excluded during synchronization

PlsFileTypes=mp3,wma – filetypes included in playlists

 

Usage Example

Dim oJBSynchApp As New JBSynch.Application
' or late bound
' Dim oJBSynch as Object
' Set oJBSynch = CreateObject("JBSynch.Application")
 
Dim oJBSynchJob As JBSynch.CJBSynchApp
' preferably you should declare oJBSynchJob as
' a module level WithEvents object so you can
' trap the various events raised by oJBSynchJob
' and implement any things you want in between
' events
 
Set oJBSynchJob = oJBSynchApp.CreateNewJob()
With oJBSynchJob
   .OpenConfig ("C:\Program Files\Jukebox Synchronizer\Default Config.cfs")
   .AllowActions(JBSynch_Synchronize) = True
   .AllowActions(JBSynch_NewFilespls) = True
   .AllowActions(JBSynch_ShuffledPls) = True
   .AllowActions(JBSynch_ManagedPls) = False
   .AllowActions(JBSynch_FolderPls) = False
   .AllowActions(JBSynch_ExternalPrograms) = False
   .AllowActions(JBSynch_SynchronizeAgain) = False
   .StartJob
End With
 
' Some other things possible are
oJBSynchJob.ShowMainUI ' to show the main wizard window
oJBSynchJob.ShowManageConfigOp JBSynch_ShowOpenConfig ' to allow the user to specify and open a config file
 
' Check out other properties and methods using Object Browser