Package conduit :: Package dataproviders :: Module DataProvider :: Class DataProviderBase
[hide private]

Class DataProviderBase

source code


Model of a DataProvider. Can be a source or a sink

Instance Methods [hide private]
 
__init__(self, *args)
All sync functionality should be provided by derived classes
source code
 
__emit_status_changed(self)
Emits a 'status-changed' signal to the main loop.
source code
 
__emit_change_detected(self)
Emits a 'change-detected' signal to the main loop.
source code
 
emit(self, *args)
Override the gobject signal emission so that all signals are emitted from the main loop on an idle handler
source code
bool
initialize(self)
Called when the module is loaded by the module loader.
source code
 
uninitialize(self)
Called just before the application quits.
source code
 
refresh(self)
Performs any (conduit.logging in, etc) which must be undertaken on the dataprovider prior to calling get_all().
source code
 
finish(self, *args)
Perform any post-sync cleanup.
source code
 
emit_change_detected(self) source code
 
set_status(self, newStatus)
Sets the dataprovider status.
source code
 
get_status(self)
Returns: The current dataproviders status
source code
 
is_busy(self)
A DataProvider is busy if it is currently in the middle of the intialization or synchronization process.
source code
 
configure(self, window)
Show a configuration box for configuring the dataprovider instance.
source code
 
is_configured(self, isSource, isTwoWay)
Checks if the dp has been configured or not (and if it needs to be)
source code
dict(string)
get_configuration(self)
Returns a dictionary of strings to be saved, representing the dataproviders current configuration.
source code
string
get_configuration_xml(self)
Returns the dataprovider configuration as xml
source code
 
set_configuration(self, config)
Restores applications settings
source code
 
set_configuration_xml(self, xmltext)
Restores applications settings from XML
source code
string
get_UID(self)
Returns a UID that represents this dataproviders (locally) unique state and configuration.
source code
 
get_input_conversion_args(self)
Provides a way to pass arguments to conversion functions.
source code
 
get_input_type(self)
Provides a way for dataproviders to change the datatype they accept.
source code
 
get_output_conversion_args(self)
Provides a way to pass arguments to conversion functions.
source code
 
get_output_type(self)
Provides a way for dataproviders to change the datatype they emit.
source code
 
get_name(self)
Returns: The DataProvider name, to be displayed in the UI
source code
Class Variables [hide private]
  __gsignals__ = {"status-changed":(gobject.SIGNAL_RUN_LAST, gob...
  _name_ = ""
  _description_ = ""
  _icon_ = ""
  _module_type_ = "dataprovider"
  _category_ = DataProviderCategory.DataProviderCategory("Test")
  _configurable_ = False
  _out_type_ = ""
  _in_type_ = ""
Method Details [hide private]

__emit_status_changed(self)

source code 

Emits a 'status-changed' signal to the main loop.

You should connect to this signal if you wish to be notified when the derived DataProvider goes through its stages (STATUS_* etc)

initialize(self)

source code 

Called when the module is loaded by the module loader.

It is called in the main thread so should NOT block. It should perform simple tests to determine whether the dataprovider is applicable to the user and whether is should be presented to them. For example it may check if a specific piece of hardware is loaded, or check if a user has the specific piece of software installed with which it synchronizes.
Returns: bool
True if the module initialized correctly (is appropriate for the user), False otherwise

refresh(self)

source code 

Performs any (conduit.logging in, etc) which must be undertaken on the dataprovider prior to calling get_all(). Should gather all information so a subsequent call to get_all() can return the uids of all the data this dataprovider holds

This function may be called multiple times so derived classes should be aware of this.

Derived classes should call this function to ensure the dataprovider status is updated.

finish(self, *args)

source code 
Perform any post-sync cleanup. For example, free any structures created in refresh that were used in the synchronization.

set_status(self, newStatus)

source code 
Sets the dataprovider status. If the status has changed then emits a status-changed signal

get_status(self)

source code 
Returns:
The current dataproviders status

is_busy(self)

source code 
A DataProvider is busy if it is currently in the middle of the intialization or synchronization process.

To Do: This simple test introduces a few (many) corner cases where the function will return the wrong result. Think about this harder

configure(self, window)

source code 
Show a configuration box for configuring the dataprovider instance.
Parameters:
  • window - The parent gtk.Window (to show a modal dialog)

is_configured(self, isSource, isTwoWay)

source code 
Checks if the dp has been configured or not (and if it needs to be)
Parameters:
  • isSource - True if the dataprovider is in the source position
  • isTwoway - True if the dataprovider is a member of a two-way sync

get_configuration(self)

source code 
Returns a dictionary of strings to be saved, representing the dataproviders current configuration. Should be overridden by all dataproviders wishing to be able to save their state between application runs
Returns: dict(string)
Dictionary of strings containing application settings

set_configuration(self, config)

source code 
Restores applications settings
Parameters:
  • config - dictionary of dataprovider settings to restore

set_configuration_xml(self, xmltext)

source code 
Restores applications settings from XML
Parameters:
  • xmltext (string) - xml representation of settings

get_UID(self)

source code 

Returns a UID that represents this dataproviders (locally) unique state and configuration. For example the LUID for a gmail dp may be your username and password.

Derived types MUST overwride this function
Returns: string

get_input_conversion_args(self)

source code 
Provides a way to pass arguments to conversion functions. For example when transcoding a music file the dataprovider may return a dictionary specifying the conversion encoding, quality, etc
Returns:
a dict of conversion arguments

get_input_type(self)

source code 
Provides a way for dataproviders to change the datatype they accept. In most cases implementing get_in_conversion args is recommended and will let you acomplish what you want.

get_output_conversion_args(self)

source code 
Provides a way to pass arguments to conversion functions. For example when transcoding a music file the dataprovider may return a dictionary specifying the conversion encoding, quality, etc
Returns:
a dict of conversion arguments

get_output_type(self)

source code 
Provides a way for dataproviders to change the datatype they emit. In most cases implementing get_out_conversion args is recommended and will let you acomplish what you want.

get_name(self)

source code 
Returns:
The DataProvider name, to be displayed in the UI

Class Variable Details [hide private]

__gsignals__

Value:
{"status-changed":(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []), "c\
hange-detected":(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])}