Changeset 2421

Show
Ignore:
Timestamp:
08/06/07 16:00:03 (1 year ago)
Author:
cstender
Message:

implemented discover function

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/irmc-sync

    • Property svn:ignore changed from
      config.log
      .sconsign.dblite
      irmc-sync.conf
      .sconf_temp
      to
      config.log
      .sconsign.dblite
      irmc-sync.conf
      .sconf_temp
      tags
  • plugins/irmc-sync/src/irmc_obex.c

    r2415 r2421  
    549549 
    550550gboolean irmc_obex_connect(obex_t* handle, char* target, OSyncError **error) { 
     551  osync_trace(TRACE_ENTRY, "%s(%p,%p,%p)", __func__, handle, target, error); 
    551552  int ret = -1; 
    552553  obex_object_t *object;  
     
    617618    } 
    618619    // Connected and serial number is OK! 
     620    osync_trace(TRACE_EXIT, "%s", __func__); 
    619621    return TRUE; 
    620622  } 
    621623  osync_error_set(error, OSYNC_ERROR_GENERIC, "Cannot connect via OBEX."); 
     624  osync_trace(TRACE_EXIT_ERROR, "%s", __func__); 
    622625  return FALSE; 
    623626} 
  • plugins/irmc-sync/src/irmc_sync.c

    r2410 r2421  
    856856} 
    857857 
    858 /** 
    859  * Establishes connection to the device. 
    860  */ 
     858/* Establish connection to the device */ 
    861859static void irmcConnect(void *data, OSyncPluginInfo *info, OSyncContext *ctx) 
    862860{ 
     
    891889    osync_context_report_osyncerror(ctx, error); 
    892890    osync_trace(TRACE_EXIT, "%s: %s", __func__, osync_error_print(&error)); 
    893     return; 
     891   return; 
    894892  } 
    895893 
     
    898896 
    899897  // check whether a slowsync is necessary 
    900  
    901898 
    902899/* TODO: port sink engine stuff.. 
     
    13361333  osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, error); 
    13371334 
    1338  // TODO: do some discover voodoo 
    1339  
     1335  irmc_environment *env = (irmc_environment *)data; 
     1336 
     1337  GList *s = NULL; 
     1338  for (s = env->databases; s; s = s->next) { 
     1339        irmc_database *sinkenv = s->data; 
     1340        osync_objtype_sink_set_available(sinkenv->sink, TRUE); 
     1341  } 
     1342 
     1343  OSyncVersion *version = osync_version_new(error); 
     1344  osync_version_set_plugin(version, "irmc-sync"); 
     1345  //osync_version_set_modelversion(version, "version"); 
     1346  //osync_version_set_firmwareversion(version, "firmwareversion"); 
     1347  //osync_version_set_softwareversion(version, "softwareversion"); 
     1348  //osync_version_set_hardwareversion(version, "hardwareversion"); 
     1349  osync_plugin_info_set_version(info, version); 
     1350  osync_version_unref(version); 
    13401351 
    13411352  osync_trace(TRACE_EXIT, "%s", __func__); 
    13421353  return TRUE; 
    1343  
    1344 // TODO : do some disvoer voodoo 
    1345 //error: 
    1346  
    1347   osync_trace(TRACE_EXIT_ERROR, "%s: %s", osync_error_print(error)); 
    1348   return FALSE; 
    1349 
    1350  
    1351 static irmc_database *create_database(OSyncPluginInfo *info, const char *objtype, const char *format, OSyncSinkGetChangesFn getchanges, OSyncSinkCommitFn commit, OSyncError **error) { 
     1354
     1355 
     1356static irmc_database *create_database(OSyncPluginInfo *info, const char *objtype, const char *format, OSyncSinkGetChangesFn getchanges, OSyncSinkCommitFn commit, OSyncError **error) 
     1357
    13521358  osync_trace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, info, objtype, format, error);        
    13531359 
     
    13561362  irmc_database *database = osync_try_malloc0(sizeof(irmc_database), error);  
    13571363  if (!database) 
    1358           goto error; 
    1359  
    1360   OSyncObjTypeSink *sink = osync_objtype_sink_new(objtype, error); 
    1361   if (!sink) 
    1362           goto error_free_db; 
    1363  
    1364     OSyncObjTypeSinkFunctions functions; 
    1365     memset(&functions, 0, sizeof(functions)); 
    1366     functions.connect = irmcConnect; 
    1367     functions.disconnect = irmcDisconnect; 
    1368     functions.sync_done = irmcSyncDone; 
    1369  
    1370     osync_objtype_sink_add_objformat(sink, format); 
    1371     functions.get_changes = getchanges; 
    1372     functions.commit = commit; 
    1373  
    1374     database->objformat = osync_format_env_find_objformat(formatenv, format); 
    1375     if (!database->objformat) { 
    1376             osync_error_set(error, OSYNC_ERROR_GENERIC, "Can't find object format \"%s\" for object type \"%s\"! " 
    1377                             "Is the vformat plugin correctly installed?", format, objtype); 
    1378             goto error_free_db; 
    1379     } 
    1380      
    1381     osync_objtype_sink_set_functions(sink, functions, database); 
    1382     osync_plugin_info_add_objtype(info, sink); 
    1383  
    1384     osync_trace(TRACE_EXIT, "%s: %p", __func__, database); 
    1385     return database; 
    1386  
    1387 error_free_db: 
    1388     g_free(database); 
    1389 error:     
    1390     osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); 
    1391     return NULL; 
    1392 
    1393  
    1394 /** 
    1395  * Initialize the connection. 
    1396  */ 
     1364    goto error; 
     1365 
     1366  database->sink = osync_objtype_sink_new(objtype, error); 
     1367  if (!database->sink) 
     1368    goto error_free_db; 
     1369 
     1370  OSyncObjTypeSinkFunctions functions; 
     1371  memset(&functions, 0, sizeof(functions)); 
     1372  functions.connect = irmcConnect; 
     1373  functions.disconnect = irmcDisconnect; 
     1374  functions.sync_done = irmcSyncDone; 
     1375  functions.get_changes = getchanges; 
     1376  functions.commit = commit; 
     1377 
     1378  osync_objtype_sink_set_functions(database->sink, functions, database); 
     1379 
     1380  database->objformat = osync_format_env_find_objformat(formatenv, format); 
     1381  if (!database->objformat) { 
     1382    osync_error_set(error, OSYNC_ERROR_GENERIC, "Can't find object format \"%s\" for object type \"%s\"! " 
     1383                                           "Is the vformat plugin correctly installed?", format, objtype); 
     1384    goto error_free_db; 
     1385  } 
     1386  osync_objtype_sink_add_objformat(database->sink, format); 
     1387 
     1388  osync_plugin_info_add_objtype(info, database->sink); 
     1389 
     1390  osync_trace(TRACE_EXIT, "%s: %p", __func__, database); 
     1391  return database; 
     1392 
     1393  error_free_db: 
     1394  g_free(database); 
     1395 
     1396  error:     
     1397  osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); 
     1398  return NULL; 
     1399
     1400 
     1401/* Initialize connection */ 
    13971402static void *irmcInitialize(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) 
    13981403{ 
     
    14001405  const char *configdata = NULL; 
    14011406 
    1402     // create new environment, where all connection information are stored in 
     1407  // create new environment, where all connection information are stored in 
    14031408  irmc_environment *env = osync_try_malloc0(sizeof(irmc_environment), error); 
    14041409  if (!env) 
    1405          goto error; 
     1410    goto error; 
    14061411 
    14071412  // retrieve the config data 
     
    14211426  env->anchor_path = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); 
    14221427 
    1423  
    14241428  irmc_database *contactdb = create_database(info, "contact", "vcard21", irmcContactGetChangeinfo, irmcContactCommitChange, error);  
    14251429  irmc_database *eventdb = create_database(info, "event", "vevent10", irmcCalendarGetChangeinfo, irmcCalendarCommitChange, error); 
    1426  
    1427 // XXX: Is there a todo database in IrMC?!   
    14281430  irmc_database *tododb = create_database(info, "todo", "vtodo10", irmcCalendarGetChangeinfo, irmcCalendarCommitChange, error); 
    14291431  irmc_database *notedb = create_database(info, "note", "vnote11", irmcNoteGetChangeinfo, irmcNoteCommitChange, error); 
     
    14371439  env->databases = g_list_append(env->databases, notedb);  
    14381440 
    1439  
    14401441  // return the environment 
    14411442  osync_trace(TRACE_EXIT, "%s: %p", __func__, env); 
     
    14431444 
    14441445error_free_env: 
    1445     free(env); 
     1446  free(env); 
     1447 
    14461448error:     
    1447     osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); 
    1448     return NULL; 
    1449 
    1450  
    1451 /** 
    1452  * Returns all information about this plugin. 
    1453  */ 
     1449  osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); 
     1450  return NULL; 
     1451
     1452 
     1453/* Return all plugin information */ 
    14541454osync_bool get_sync_info(OSyncPluginEnv *env, OSyncError **error) 
    14551455{ 
    1456  
    14571456  OSyncPlugin *plugin = osync_plugin_new(error); 
    14581457  if (!plugin) 
    1459           goto error; 
     1458    goto error; 
    14601459 
    14611460  osync_plugin_set_name(plugin, "irmc-sync"); 
     
    14701469  osync_plugin_unref(plugin); 
    14711470 
    1472 /* 
    1473   osync_plugin_accept_objtype(info, "contact"); 
    1474   osync_plugin_accept_objformat(info, "contact", "vcard21", NULL); 
    1475   osync_plugin_set_commit_objformat(info, "contact", "vcard21", irmcContactCommitChange); 
    1476  
    1477   osync_plugin_accept_objtype(info, "event"); 
    1478   osync_plugin_accept_objformat(info, "event", "vevent10", NULL); 
    1479   osync_plugin_set_commit_objformat(info, "event", "vevent10", irmcCalendarCommitChange); 
    1480  
    1481   osync_plugin_accept_objtype(info, "todo"); 
    1482   osync_plugin_accept_objformat(info, "todo", "vtodo10", NULL); 
    1483   osync_plugin_set_commit_objformat(info, "todo", "vtodo10", irmcCalendarCommitChange); 
    1484  
    1485   osync_plugin_accept_objtype(info, "note"); 
    1486   osync_plugin_accept_objformat(info, "note", "vnote11", NULL); 
    1487   osync_plugin_set_commit_objformat(info, "note", "vnote11", irmcNoteCommitChange); 
    1488 */ 
    14891471  return TRUE; 
    14901472 
  • plugins/irmc-sync/src/irmc_sync.h

    r2410 r2421  
    6666typedef struct irmc_database { 
    6767  OSyncObjFormat *objformat;     // The configured objformat for this database 
     68  OSyncObjTypeSink *sink; 
    6869  unsigned int changecounter;    
    6970  char *dbid;