Changeset 1763
- Timestamp:
- 02/19/07 17:17:06 (22 months ago)
- Location:
- plugins/kdepim/src
- Files:
-
- 3 modified
-
kdepim_impl.cpp (modified) (10 diffs)
-
kdepim_sync.cpp (modified) (4 diffs)
-
osyncbase.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/kdepim/src/kdepim_impl.cpp
r1757 r1763 43 43 #include "osyncbase.h" 44 44 #include "kaddrbook.h" 45 #include "kcal.h"46 #include "knotes.h"45 //#include "kcal.h" 46 //#include "knotes.h" 47 47 static bool sentinal = false; 48 48 … … 50 50 { 51 51 public: 52 KdePluginImplementation( OSyncMember *member ) 53 : mMember( member ), 54 mApplication( 0 ), 52 KdePluginImplementation(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) 53 : mApplication( 0 ), 55 54 mNewApplication( false ) 56 55 {} … … 84 83 } 85 84 86 bool init(OSync Error **error)85 bool init(OSyncPluginInfo *info, OSyncError **error) 87 86 { 88 87 osync_trace(TRACE_ENTRY, "%s(%p)", __func__, error); … … 90 89 initKDE(); 91 90 92 mHashtable = osync_hashtable_new(); 91 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 92 QString tablepath = QString("%1/hashtable.db").arg(osync_plugin_info_get_configdir(info)); 93 mHashtable = osync_hashtable_new(tablepath, osync_objtype_sink_get_name(sink), error); 93 94 94 95 mKaddrbook = new KContactDataSource(mMember, mHashtable); … … 109 110 } 110 111 111 virtual void connect(OSync Context *ctx)112 virtual void connect(OSyncPluginInfo * /*info*/, OSyncContext *ctx) 112 113 { 113 114 osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); 114 115 115 OSyncError *error = NULL; 116 if ( !osync_hashtable_load(mHashtable, mMember, &error) ) { 117 osync_context_report_osyncerror(ctx, &error); 118 osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); 119 osync_error_free(&error); 120 return; 121 } 116 // OSyncError *error = NULL; 122 117 123 if (mKaddrbook && osync_member_objtype_enabled(mMember, "contact") &&\118 if (mKaddrbook && \ 124 119 !mKaddrbook->connect(ctx)) { 125 120 osync_trace(TRACE_EXIT_ERROR, "%s: Unable to open addressbook", __func__); … … 131 126 } 132 127 133 virtual void disconnect(OSync Context *ctx)128 virtual void disconnect(OSyncPluginInfo * /*info*/, OSyncContext *ctx) 134 129 { 135 osync_hashtable_close(mHashtable);136 137 130 if (mKaddrbook && mKaddrbook->connected && !mKaddrbook->disconnect(ctx)) 138 131 return; … … 142 135 143 136 144 virtual void sync_done(OSync Context *ctx)137 virtual void sync_done(OSyncPluginInfo *info, OSyncContext *ctx) 145 138 { 146 139 if (mKaddrbook && mKaddrbook->connected) 147 140 { 148 osync_anchor_update(mMember, "contact", "true"); 141 QString anchorpath = QString("%1/anchor.db").arg(osync_plugin_info_get_configdir(info)); 142 osync_anchor_update(anchorpath, "contact", "true"); 149 143 } 150 144 osync_context_report_success(ctx); 151 145 } 152 146 153 virtual void get_changeinfo(OSync Context *ctx)147 virtual void get_changeinfo(OSyncPluginInfo * /*info*/, OSyncContext *ctx) 154 148 { 155 149 if (mKaddrbook && mKaddrbook->connected && !mKaddrbook->contact_get_changeinfo(ctx)) … … 158 152 } 159 153 160 virtual bool vcard_access(OSync Context *ctx, OSyncChange *chg)154 virtual bool vcard_access(OSyncPluginInfo * /*info*/, OSyncContext *ctx, OSyncChange *chg) 161 155 { 162 156 if (mKaddrbook) … … 169 163 } 170 164 171 virtual bool vcard_commit_change(OSync Context *ctx, OSyncChange *chg)165 virtual bool vcard_commit_change(OSyncPluginInfo * /*info*/, OSyncContext *ctx, OSyncChange *chg) 172 166 { 173 167 if (mKaddrbook) … … 195 189 KdePluginImplementationBase *new_KdePluginImplementation(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) { 196 190 KdePluginImplementation *imp = new KdePluginImplementation(plugin, info, error); 197 if (!imp->init( error)) {191 if (!imp->init(info, error)) { 198 192 delete imp; 199 193 return 0; -
plugins/kdepim/src/kdepim_sync.cpp
r1760 r1763 26 26 27 27 #include <dlfcn.h> 28 #include <string.h> 28 29 29 30 #include "osyncbase.h" 30 31 31 static KdePluginImplementationBase *impl_object_for_context(OSyncContext *ctx) 32 { 33 return (KdePluginImplementationBase *)osync_context_get_plugin_data(ctx); 32 33 static void kde_finalize(void *userdata) 34 { 35 // osync_debug("kde", 3, "%s()", __FUNCTION__); 36 37 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)userdata; 38 delete impl_object; 39 } 40 41 static void kde_connect(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx) 42 { 43 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase*)userdata; 44 impl_object->connect(info, ctx); 45 } 46 47 48 static void kde_disconnect(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx) 49 { 50 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)userdata; 51 impl_object->disconnect(info, ctx); 52 } 53 54 static void kde_get_changeinfo(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx) 55 { 56 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase*)userdata; 57 // osync_debug("kde", 3, "%s",__FUNCTION__); 58 59 impl_object->get_changeinfo(info, ctx); 60 } 61 62 static void kde_sync_done(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx) 63 { 64 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)userdata; 65 66 // osync_debug("kde", 3, "%s()",__FUNCTION__); 67 68 impl_object->sync_done(info, ctx); 69 } 70 71 static void kde_vcard_commit_change(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) 72 { 73 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)userdata; 74 75 // osync_debug("kde", 3, "%s()",__FUNCTION__); 76 77 impl_object->vcard_commit_change(info, ctx, change); 78 } 79 80 static osync_bool kde_vcard_access(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) 81 { 82 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)userdata; 83 84 // osync_debug("kde", 3, "%s()",__FUNCTION__); 85 86 impl_object->vcard_access(info, ctx, change); 34 87 } 35 88 … … 69 122 goto error; 70 123 124 do { 125 OSyncObjTypeSink *sink = osync_objtype_sink_new("contact", error); 126 if (!sink) 127 goto error; 128 129 osync_objtype_sink_add_objformat(sink, "vcard30"); 130 131 /* Every sink can have different functions ... */ 132 OSyncObjTypeSinkFunctions functions; 133 memset(&functions, 0, sizeof(functions)); 134 functions.connect = kde_connect; 135 functions.disconnect = kde_disconnect; 136 functions.get_changes = kde_get_changeinfo; 137 functions.commit = kde_vcard_commit_change; 138 functions.sync_done = kde_sync_done; 139 140 /* We pass the OSyncFileDir object to the sink, so we dont have to look it up 141 * again once the functions are called */ 142 osync_objtype_sink_set_functions(sink, functions, impl_object); 143 osync_plugin_info_add_objtype(info, sink); 144 145 } while(0); 146 147 71 148 /* Return the created object to the sync engine */ 72 149 return (void*)impl_object; … … 75 152 } 76 153 77 static void kde_finalize(void *data)78 {79 // osync_debug("kde", 3, "%s()", __FUNCTION__);80 81 KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)data;82 delete impl_object;83 }84 85 static void kde_connect(OSyncContext *ctx)86 {87 KdePluginImplementationBase *impl_object = impl_object_for_context(ctx);88 impl_object->connect(ctx);89 }90 91 92 static void kde_disconnect(OSyncContext *ctx)93 {94 KdePluginImplementationBase *impl_object = impl_object_for_context(ctx);95 impl_object->disconnect(ctx);96 }97 98 static void kde_get_changeinfo(OSyncContext *ctx)99 {100 KdePluginImplementationBase *impl_object = impl_object_for_context(ctx);101 // osync_debug("kde", 3, "%s",__FUNCTION__);102 103 impl_object->get_changeinfo(ctx);104 }105 106 static void kde_sync_done(OSyncContext *ctx)107 {108 KdePluginImplementationBase *impl_object = impl_object_for_context(ctx);109 110 // osync_debug("kde", 3, "%s()",__FUNCTION__);111 112 impl_object->sync_done(ctx);113 }114 115 static osync_bool kde_vcard_commit_change(OSyncContext *ctx, OSyncChange *change)116 {117 KdePluginImplementationBase *impl_object = impl_object_for_context(ctx);118 119 // osync_debug("kde", 3, "%s()",__FUNCTION__);120 121 return impl_object->vcard_commit_change(ctx, change);122 }123 124 static osync_bool kde_vcard_access(OSyncContext *ctx, OSyncChange *change)125 {126 KdePluginImplementationBase *impl_object = impl_object_for_context(ctx);127 128 // osync_debug("kde", 3, "%s()",__FUNCTION__);129 130 return impl_object->vcard_access(ctx, change);131 }132 133 154 extern "C" 134 155 { … … 148 169 } 149 170 150 osync_bool get_sync_info(OSyncEnv *env, OSyncError **error) { 151 152 //OSyncPluginInfo *info = osync_plugin_new_info(env); 171 osync_bool get_sync_info(OSyncPluginEnv *env, OSyncError **error) { 172 153 173 OSyncPlugin *plugin = osync_plugin_new(error); 154 174 if (!plugin) 155 175 goto error; 156 176 157 //info->version = 1;158 //now in int get_version(void);159 160 //info->name = "kdepim-sync";161 177 osync_plugin_set_name(plugin, "kdepim-sync"); 162 //info->longname = "KDE Desktop";163 178 osync_plugin_set_longname(plugin, "KDE Desktop"); 164 //info->description = "Plugin for the KDE 3.5 Desktop";165 179 osync_plugin_set_description(plugin, "Plugin for the KDE 3.5 Desktop"); 166 180 167 //info->config_type = NO_CONFIGURATION;168 181 osync_plugin_set_config_type(plugin, OSYNC_PLUGIN_NO_CONFIGURATION); 169 182 170 //info->functions.initialize = kde_initialize;171 183 osync_plugin_set_initialize(plugin, kde_initialize); 172 173 //info->functions.connect = kde_connect;174 //now in initialize175 //info->functions.disconnect = kde_disconnect;176 //now in finalize177 178 //info->functions.finalize = kde_finalize;179 184 osync_plugin_set_finalize(plugin, kde_finalize); 180 185 osync_plugin_set_discover(plugin, kde_discover); 181 182 info->functions.get_changeinfo = kde_get_changeinfo; 183 info->functions.sync_done = kde_sync_done; 186 184 187 185 188 osync_plugin_env_register_plugin(env, plugin); -
plugins/kdepim/src/osyncbase.h
r1760 r1763 24 24 { 25 25 public: 26 virtual void connect(OSync Context *ctx) = 0;27 virtual void disconnect(OSync Context *ctx) = 0;26 virtual void connect(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 27 virtual void disconnect(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 28 28 29 virtual void get_changeinfo(OSync Context *ctx) = 0;29 virtual void get_changeinfo(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 30 30 31 virtual void sync_done(OSync Context *ctx) = 0;31 virtual void sync_done(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 32 32 33 virtual bool vcard_access(OSync Context *ctx, OSyncChange *chg) = 0;34 virtual bool vcard_commit_change(OSync Context *ctx, OSyncChange *chg) = 0;33 virtual bool vcard_access(OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *chg) = 0; 34 virtual bool vcard_commit_change(OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *chg) = 0; 35 35 36 36
