Ticket #208: exp.patch

File exp.patch, 9.4 kB (added by pmarat, 2 years ago)

appended is a patch for current svn version (1062) libopensync-plugin-kdepim. kdepim-sync with xml configuration

  • configure.in

    old new  
    3939AC_SUBST(OPENSYNC_HEADERDIR) 
    4040AC_SUBST(OPENSYNC_INCLUDEDIR) 
    4141AC_SUBST(OPENSYNC_LIBDIR) 
     42AC_SUBST(XML_CFLAGS) 
     43AC_SUBST(XML_LIBS) 
    4244 
    4345## AC_CHECK_HEADER(${$ac_kde_includes}/libkcal/resourcecalendar.h) 
    4446 
  • src/kdepim-sync

    old new  
  • src/kdepim_sync.cpp

    old new  
    183183    /*FIXME: i18n */ 
    184184    info->longname = "KDE Desktop"; 
    185185    info->description = "Plugin for the KDE 3.5 Desktop"; 
    186     info->config_type = NO_CONFIGURATION; 
    187186 
    188187    info->functions.initialize = kde_initialize; 
    189188    info->functions.connect = kde_connect; 
  • src/kdepim_impl.cpp

    old new  
    3333#include <kapplication.h> 
    3434#include <kcmdlineargs.h> 
    3535#include <kaboutdata.h> 
     36#include <libxml/xmlmemory.h> 
     37#include <libxml/parser.h> 
    3638 
    3739#include <qsignal.h> 
    3840 
     
    5456        mApplication( 0 ), 
    5557        mNewApplication( false ) 
    5658    { 
     59      isKcal=false; isKaddrbook=false; isKnotes=false; isTodo=false; 
     60      mKcal = 0; mKnotes = 0; mKaddrbook=0; 
    5761    } 
    5862 
    5963    void initKDE() 
     
    9195      initKDE(); 
    9296 
    9397      mHashtable = osync_hashtable_new(); 
     98      char *configData = NULL; 
     99      int configSize = 0; 
    94100 
    95       mKcal = new KCalDataSource(mMember, mHashtable); 
    96       mKnotes = new KNotesDataSource(mMember, mHashtable); 
    97       mKaddrbook = new KContactDataSource(mMember, mHashtable); 
     101      //now get the config file for this plugin 
     102      if (!osync_member_get_config(mMember, &configData, &configSize, error)) { 
     103        osync_error_update(error, "Unable to get config data: %s", osync_error_print(error)); 
     104        isKcal=true; isKaddrbook=true; isKnotes=true; 
     105      } 
     106      xmlDocPtr doc = xmlParseMemory(configData, configSize); 
     107      xmlNodePtr cur; 
     108      if (doc) { 
     109        if ( (cur=xmlDocGetRootElement(doc)) && 
     110          (!xmlStrcmp(cur->name, (xmlChar*)"config")) ) { 
     111          cur = cur->xmlChildrenNode; 
     112          while (cur != NULL) { 
     113            xmlChar *str = xmlNodeGetContent(cur); 
     114            if (str) { 
     115              if (!xmlStrcmp(cur->name, (const xmlChar *)"contacts")) { 
     116                isKaddrbook = ( !xmlStrcmp(str, (const xmlChar *)"true") ? 
     117                              (true): (false) ); 
     118              } 
     119              if (!xmlStrcmp(cur->name, (const xmlChar *)"calendar")) { 
     120                isKcal = ( !xmlStrcmp(str, (const xmlChar *)"true") ? 
     121                         (true): (false) ); 
     122              } 
     123              if (!xmlStrcmp(cur->name, (const xmlChar *)"notes")) { 
     124                isKnotes = ( !xmlStrcmp(str, (const xmlChar *)"true") ? 
     125                           (true): (false) ); 
     126              } 
     127              if (!xmlStrcmp(cur->name, (const xmlChar *)"todo")) { 
     128                isTodo = ( !xmlStrcmp(str, (const xmlChar *)"true") ? 
     129                         (true): (false) ); 
     130              } 
     131              xmlFree(str); 
     132            } 
     133            cur = cur->next; 
     134          }  
     135        } 
     136        xmlFreeDoc(doc); 
     137      } 
    98138 
     139      if (isKcal) { 
     140        mKcal = new KCalDataSource(mMember, mHashtable); 
     141      } 
     142      if (isKnotes) { 
     143        mKnotes = new KNotesDataSource(mMember, mHashtable); 
     144      } 
     145      if (isKaddrbook) { 
     146        mKaddrbook = new KContactDataSource(mMember, mHashtable); 
     147      } 
     148 
    99149      osync_trace(TRACE_EXIT, "%s", __func__); 
    100150      return true; 
    101151    } 
    102152 
    103153    virtual ~KdePluginImplementation() 
    104154    { 
    105       delete mKcal; 
    106       mKcal = 0; 
    107  
    108       delete mKnotes; 
    109       mKnotes = 0; 
    110  
     155      if (isKcal) { 
     156        delete mKcal; 
     157        mKcal = 0; 
     158      } 
     159      if (isKnotes) { 
     160        delete mKnotes; 
     161        mKnotes = 0; 
     162      } 
     163      if (isKaddrbook) { 
     164        delete mKaddrbook; 
     165        mKaddrbook=0; 
     166      } 
    111167      if ( mNewApplication ) { 
    112168        delete mApplication; 
    113169        mApplication = 0; 
     
    130186      } 
    131187 
    132188 
    133       if (mKcal && (osync_member_objtype_enabled(mMember, "todo") || 
     189      if (isKcal && ( ((isTodo) && osync_member_objtype_enabled(mMember, "todo")) || 
    134190          osync_member_objtype_enabled(mMember, "event")) && !mKcal->connect(ctx)) { 
    135191        osync_trace(TRACE_EXIT_ERROR, "%s: Unable to open calendar", __func__); 
    136192        return; 
    137193      } 
    138194 
    139       if (mKnotes && osync_member_objtype_enabled(mMember, "note") && \ 
     195      if (isKnotes && osync_member_objtype_enabled(mMember, "note") && \ 
    140196          !mKnotes->connect(ctx)) { 
    141197        osync_trace(TRACE_EXIT_ERROR, "%s: Unable to open notes", __func__); 
    142198        return; 
    143199      } 
    144200 
    145       if (mKaddrbook && osync_member_objtype_enabled(mMember, "contact") && \ 
     201      if (isKaddrbook && osync_member_objtype_enabled(mMember, "contact") && \ 
    146202          !mKaddrbook->connect(ctx)) { 
    147203        osync_trace(TRACE_EXIT_ERROR, "%s: Unable to open addressbook", __func__); 
    148204        return; 
     
    156212    { 
    157213      osync_hashtable_close(mHashtable); 
    158214 
    159       if (mKcal && mKcal->connected && !mKcal->disconnect(ctx)) 
     215      if (isKcal && mKcal->connected && !mKcal->disconnect(ctx)) 
    160216        return; 
    161       if (mKnotes && mKnotes->connected && !mKnotes->disconnect(ctx)) 
     217      if (isKnotes && mKnotes->connected && !mKnotes->disconnect(ctx)) 
    162218        return; 
    163       if (mKaddrbook && mKaddrbook->connected && !mKaddrbook->disconnect(ctx)) 
     219      if (isKaddrbook && mKaddrbook->connected && !mKaddrbook->disconnect(ctx)) 
    164220        return; 
    165221 
    166222      osync_context_report_success(ctx); 
     
    168224 
    169225    virtual void get_changeinfo(OSyncContext *ctx) 
    170226    { 
    171       if (mKaddrbook && mKaddrbook->connected && !mKaddrbook->contact_get_changeinfo(ctx)) 
     227      if (isKaddrbook && mKaddrbook->connected && !mKaddrbook->contact_get_changeinfo(ctx)) 
    172228        return; 
    173229 
    174       if (mKcal && mKcal->connected && !mKcal->get_changeinfo_events(ctx)) 
     230      if (isKcal && mKcal->connected && !mKcal->get_changeinfo_events(ctx)) 
    175231        return; 
    176232 
    177       if (mKcal && mKcal->connected && !mKcal->get_changeinfo_todos(ctx)) 
     233      if (isKcal && isTodo && mKcal->connected && !mKcal->get_changeinfo_todos(ctx)) 
    178234        return; 
    179235 
    180       if (mKnotes && mKnotes->connected && !mKnotes->get_changeinfo(ctx)) 
     236      if (isKnotes && mKnotes->connected && !mKnotes->get_changeinfo(ctx)) 
    181237        return; 
    182238 
    183239      osync_context_report_success(ctx); 
     
    185241 
    186242    virtual bool vcard_access(OSyncContext *ctx, OSyncChange *chg) 
    187243    { 
    188       if (mKaddrbook) 
     244      if (isKaddrbook && mKaddrbook) 
    189245        return mKaddrbook->vcard_access(ctx, chg); 
    190246      else { 
    191247        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No addressbook loaded"); 
     
    196252 
    197253    virtual bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg) 
    198254    { 
    199       if (mKaddrbook) 
     255      if (isKaddrbook && mKaddrbook) 
    200256        return mKaddrbook->vcard_commit_change(ctx, chg); 
    201257      else { 
    202258        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No addressbook loaded"); 
     
    207263 
    208264    virtual bool event_access(OSyncContext *ctx, OSyncChange *chg) 
    209265    { 
    210       if (mKcal) 
     266      if (isKcal && mKcal) 
    211267        return mKcal->event_access(ctx, chg); 
    212268      else { 
    213269        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No calendar loaded"); 
     
    218274 
    219275    virtual bool event_commit_change(OSyncContext *ctx, OSyncChange *chg) 
    220276    { 
    221       if (mKcal) 
     277      if (isKcal && mKcal) 
    222278        return mKcal->event_commit_change(ctx, chg); 
    223279      else { 
    224280        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No calendar loaded"); 
     
    229285 
    230286    virtual bool todo_access(OSyncContext *ctx, OSyncChange *chg) 
    231287    { 
    232       if (mKcal) 
     288      if (isKcal && isTodo && mKcal) 
    233289        return mKcal->todo_access(ctx, chg); 
    234290      else { 
    235291        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No calendar loaded"); 
     
    240296 
    241297    virtual bool todo_commit_change(OSyncContext *ctx, OSyncChange *chg) 
    242298    { 
    243       if (mKcal) 
     299      if (isKcal && isTodo && mKcal) 
    244300        return mKcal->todo_commit_change(ctx, chg); 
    245301      else { 
    246302        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No calendar loaded"); 
     
    251307 
    252308    virtual bool note_access(OSyncContext *ctx, OSyncChange *chg) 
    253309    { 
    254       if (mKnotes) 
     310      if (isKnotes && mKnotes) 
    255311        return mKnotes->access(ctx, chg); 
    256312      else { 
    257313        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No notes loaded"); 
     
    262318 
    263319    virtual bool note_commit_change(OSyncContext *ctx, OSyncChange *chg) 
    264320    { 
    265       if (mKnotes) 
     321      if (isKnotes && mKnotes) 
    266322        return mKnotes->commit_change(ctx, chg); 
    267323      else { 
    268324        osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No notes loaded"); 
     
    281337 
    282338    KApplication *mApplication; 
    283339    bool mNewApplication; 
     340    bool isKcal; 
     341    bool isKnotes; 
     342    bool isKaddrbook; 
     343    bool isTodo; 
    284344}; 
    285345 
    286346