Changeset 1763

Show
Ignore:
Timestamp:
02/19/07 17:17:06 (22 months ago)
Author:
dgollub
Message:

Some other porting trials.. still not useable.

Location:
plugins/kdepim/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • plugins/kdepim/src/kdepim_impl.cpp

    r1757 r1763  
    4343#include "osyncbase.h" 
    4444#include "kaddrbook.h" 
    45 #include "kcal.h" 
    46 #include "knotes.h" 
     45//#include "kcal.h" 
     46//#include "knotes.h" 
    4747static bool sentinal = false; 
    4848 
     
    5050{ 
    5151        public: 
    52                 KdePluginImplementation( OSyncMember *member ) 
    53                                 : mMember( member ), 
    54                                 mApplication( 0 ), 
     52                KdePluginImplementation(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) 
     53                                : mApplication( 0 ), 
    5554                                mNewApplication( false ) 
    5655                {} 
     
    8483                } 
    8584 
    86                 bool init(OSyncError **error) 
     85                bool init(OSyncPluginInfo *info, OSyncError **error) 
    8786                { 
    8887                        osync_trace(TRACE_ENTRY, "%s(%p)", __func__, error); 
     
    9089                        initKDE(); 
    9190 
    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); 
    9394 
    9495                        mKaddrbook = new KContactDataSource(mMember, mHashtable); 
     
    109110                } 
    110111 
    111                 virtual void connect(OSyncContext *ctx) 
     112                virtual void connect(OSyncPluginInfo * /*info*/, OSyncContext *ctx) 
    112113                { 
    113114                        osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); 
    114115 
    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; 
    122117 
    123                         if (mKaddrbook && osync_member_objtype_enabled(mMember, "contact") && \ 
     118                        if (mKaddrbook && \ 
    124119                                !mKaddrbook->connect(ctx)) { 
    125120                                osync_trace(TRACE_EXIT_ERROR, "%s: Unable to open addressbook", __func__); 
     
    131126                } 
    132127 
    133                 virtual void disconnect(OSyncContext *ctx) 
     128                virtual void disconnect(OSyncPluginInfo * /*info*/, OSyncContext *ctx) 
    134129                { 
    135                         osync_hashtable_close(mHashtable); 
    136  
    137130                        if (mKaddrbook && mKaddrbook->connected && !mKaddrbook->disconnect(ctx)) 
    138131                                return; 
     
    142135 
    143136 
    144                 virtual void sync_done(OSyncContext *ctx) 
     137                virtual void sync_done(OSyncPluginInfo *info, OSyncContext *ctx) 
    145138                { 
    146139                        if (mKaddrbook && mKaddrbook->connected) 
    147140                        { 
    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"); 
    149143                        } 
    150144                        osync_context_report_success(ctx); 
    151145                } 
    152146 
    153                 virtual void get_changeinfo(OSyncContext *ctx) 
     147                virtual void get_changeinfo(OSyncPluginInfo * /*info*/, OSyncContext *ctx) 
    154148                { 
    155149                        if (mKaddrbook && mKaddrbook->connected && !mKaddrbook->contact_get_changeinfo(ctx)) 
     
    158152                } 
    159153 
    160                 virtual bool vcard_access(OSyncContext *ctx, OSyncChange *chg) 
     154                virtual bool vcard_access(OSyncPluginInfo * /*info*/, OSyncContext *ctx, OSyncChange *chg) 
    161155                { 
    162156                        if (mKaddrbook) 
     
    169163                } 
    170164 
    171                 virtual bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg) 
     165                virtual bool vcard_commit_change(OSyncPluginInfo * /*info*/, OSyncContext *ctx, OSyncChange *chg) 
    172166                { 
    173167                        if (mKaddrbook) 
     
    195189        KdePluginImplementationBase *new_KdePluginImplementation(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) { 
    196190                KdePluginImplementation *imp = new KdePluginImplementation(plugin, info, error); 
    197                 if (!imp->init(error)) { 
     191                if (!imp->init(info, error)) { 
    198192                        delete imp; 
    199193                        return 0; 
  • plugins/kdepim/src/kdepim_sync.cpp

    r1760 r1763  
    2626 
    2727#include <dlfcn.h> 
     28#include <string.h> 
    2829 
    2930#include "osyncbase.h" 
    3031 
    31 static KdePluginImplementationBase *impl_object_for_context(OSyncContext *ctx) 
    32 { 
    33         return (KdePluginImplementationBase *)osync_context_get_plugin_data(ctx); 
     32 
     33static 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 
     41static 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 
     48static void kde_disconnect(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx) 
     49{ 
     50        KdePluginImplementationBase *impl_object = (KdePluginImplementationBase *)userdata; 
     51        impl_object->disconnect(info, ctx); 
     52} 
     53 
     54static 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 
     62static 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 
     71static 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 
     80static 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); 
    3487} 
    3588 
     
    69122                goto error; 
    70123 
     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 
    71148        /* Return the created object to the sync engine */ 
    72149        return (void*)impl_object; 
     
    75152} 
    76153 
    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  
    133154extern "C" 
    134155{ 
     
    148169} 
    149170 
    150 osync_bool get_sync_info(OSyncEnv *env, OSyncError **error) { 
    151  
    152         //OSyncPluginInfo *info = osync_plugin_new_info(env); 
     171osync_bool get_sync_info(OSyncPluginEnv *env, OSyncError **error) { 
     172 
    153173        OSyncPlugin *plugin = osync_plugin_new(error); 
    154174        if (!plugin) 
    155175                goto error; 
    156176 
    157         //info->version = 1; 
    158         //now in int get_version(void); 
    159  
    160         //info->name = "kdepim-sync"; 
    161177        osync_plugin_set_name(plugin, "kdepim-sync"); 
    162         //info->longname = "KDE Desktop"; 
    163178        osync_plugin_set_longname(plugin, "KDE Desktop"); 
    164         //info->description = "Plugin for the KDE 3.5 Desktop"; 
    165179        osync_plugin_set_description(plugin, "Plugin for the KDE 3.5 Desktop"); 
    166180 
    167         //info->config_type = NO_CONFIGURATION; 
    168181        osync_plugin_set_config_type(plugin, OSYNC_PLUGIN_NO_CONFIGURATION); 
    169182 
    170         //info->functions.initialize = kde_initialize; 
    171183        osync_plugin_set_initialize(plugin, kde_initialize); 
    172          
    173         //info->functions.connect = kde_connect; 
    174         //now in initialize 
    175         //info->functions.disconnect = kde_disconnect; 
    176         //now in finalize 
    177  
    178         //info->functions.finalize = kde_finalize; 
    179184        osync_plugin_set_finalize(plugin, kde_finalize); 
    180185        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 
    184187 
    185188        osync_plugin_env_register_plugin(env, plugin); 
  • plugins/kdepim/src/osyncbase.h

    r1760 r1763  
    2424{ 
    2525        public: 
    26                 virtual void connect(OSyncContext *ctx) = 0; 
    27                 virtual void disconnect(OSyncContext *ctx) = 0; 
     26                virtual void connect(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 
     27                virtual void disconnect(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 
    2828 
    29                 virtual void get_changeinfo(OSyncContext *ctx) = 0; 
     29                virtual void get_changeinfo(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 
    3030 
    31                 virtual void sync_done(OSyncContext *ctx) = 0; 
     31                virtual void sync_done(OSyncPluginInfo *info, OSyncContext *ctx) = 0; 
    3232 
    33                 virtual bool vcard_access(OSyncContext *ctx, OSyncChange *chg) = 0; 
    34                 virtual bool vcard_commit_change(OSyncContext *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; 
    3535 
    3636