Changeset 1618

Show
Ignore:
Timestamp:
01/20/07 02:39:31 (23 months ago)
Author:
mjahn
Message:

apply fix based one XMPM changes against OpenSync??? kdepim plugin 0560-dont_report_empty_notes.patch

Files:
1 modified

Legend:

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

    r1617 r1618  
    136136        osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); 
    137137        QMap <KNoteID_t,QString> fNotes; 
    138          
     138 
    139139        fNotes = kn_iface->notes(); 
    140140        if (kn_iface->status() != DCOPStub::CallSucceeded) { 
     
    143143                return FALSE; 
    144144        } 
    145          
     145 
    146146        if (osync_member_get_slow_sync(member, "note")) { 
    147147                osync_debug("kcal", 3, "Setting slow-sync for notes"); 
    148148                osync_hashtable_set_slow_sync(hashtable, "note"); 
    149149        } 
    150          
     150 
    151151        QMap<KNoteID_t,QString>::ConstIterator i; 
    152152        for (i = fNotes.begin(); i != fNotes.end(); i++) { 
     153                /* XXX: don't report empty notes, knotes always 
     154                 * "keeps" at least one 
     155                 */ 
     156                if (kn_iface->text(i.key()) == "") { 
     157                        osync_debug("knotes", 4, "Skipping empty note"); 
     158                        continue; 
     159                } 
     160 
    153161                osync_debug("knotes", 4, "Note key: %s", (const char*)i.key().local8Bit()); 
    154         osync_debug("knotes", 4, "Note summary: %s", (const char*)i.data().local8Bit()); 
     162                osync_debug("knotes", 4, "Note summary: %s", (const char*)i.data().local8Bit()); 
    155163                osync_trace(TRACE_INTERNAL, "reporting notes %s\n", (const char*)i.key().local8Bit()); 
    156                  
    157         QString uid = i.key(); 
     164 
     165                QString uid = i.key(); 
    158166                QString hash = NULL; 
    159         // Create osxml doc containing the note 
    160         xmlDoc *doc = xmlNewDoc((const xmlChar*)"1.0"); 
    161         xmlNode *root = osxml_node_add_root(doc, "Note"); 
    162  
    163         OSyncXMLEncoding enc; 
    164         enc.encoding = OSXML_8BIT; 
    165         enc.charset = OSXML_UTF8; 
    166  
    167         // Set the right attributes 
    168         xmlNode *sum = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); 
    169         QCString utf8str = i.data().utf8(); 
    170         hash = utf8str; 
    171         osxml_node_set(sum, "Summary", utf8str, enc); 
    172  
    173         utf8str = strip_html(kn_iface->text(i.key())).utf8(); 
    174         hash += utf8str; 
    175         if (utf8str && !utf8str.isEmpty()) { 
    176                 xmlNode *body = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); 
    177                 osxml_node_set(body, "Body", utf8str, enc); 
    178         } 
    179                  
    180         // initialize the change object 
    181         OSyncChange *chg = osync_change_new(); 
    182         osync_change_set_uid(chg, uid.local8Bit()); 
    183         osync_change_set_member(chg, member); 
    184  
    185         // object type and format 
    186         osync_change_set_objtype_string(chg, "note"); 
    187         osync_change_set_objformat_string(chg, "xml-note"); 
    188         osync_change_set_data(chg, (char*)doc, sizeof(doc), 1); 
     167                // Create osxml doc containing the note 
     168                xmlDoc *doc = xmlNewDoc((const xmlChar*)"1.0"); 
     169                xmlNode *root = osxml_node_add_root(doc, "Note"); 
     170 
     171                OSyncXMLEncoding enc; 
     172                enc.encoding = OSXML_8BIT; 
     173                enc.charset = OSXML_UTF8; 
     174 
     175                // Set the right attributes 
     176                xmlNode *sum = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); 
     177                QCString utf8str = i.data().utf8(); 
     178                hash = utf8str; 
     179                osxml_node_set(sum, "Summary", utf8str, enc); 
     180 
     181                utf8str = strip_html(kn_iface->text(i.key())).utf8(); 
     182                hash += utf8str; 
     183                if (utf8str && !utf8str.isEmpty()) { 
     184                        xmlNode *body = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); 
     185                        osxml_node_set(body, "Body", utf8str, enc); 
     186                } 
     187 
     188                // initialize the change object 
     189                OSyncChange *chg = osync_change_new(); 
     190                osync_change_set_uid(chg, uid.local8Bit()); 
     191                osync_change_set_member(chg, member); 
     192 
     193                // object type and format 
     194                osync_change_set_objtype_string(chg, "note"); 
     195                osync_change_set_objformat_string(chg, "xml-note"); 
     196                osync_change_set_data(chg, (char*)doc, sizeof(doc), 1); 
    189197 
    190198                osync_debug("knotes", 4, "Reporting note:\%s", osync_change_get_printable(chg)); 
    191199 
    192         // Use the hash table to check if the object 
    193         // needs to be reported 
    194         osync_change_set_hash(chg, hash.data()); 
    195         if (osync_hashtable_detect_change(hashtable, chg)) { 
    196             osync_context_report_change(ctx, chg); 
    197             osync_hashtable_update_hash(hashtable, chg); 
    198         } 
    199     } 
    200  
    201     osync_hashtable_report_deleted(hashtable, ctx, "note"); 
    202  
    203         osync_trace(TRACE_EXIT, "%s", __func__); 
    204     return true; 
     200                // Use the hash table to check if the object 
     201                // needs to be reported 
     202                osync_change_set_hash(chg, hash.data()); 
     203                if (osync_hashtable_detect_change(hashtable, chg)) { 
     204                        osync_context_report_change(ctx, chg); 
     205                        osync_hashtable_update_hash(hashtable, chg); 
     206                } 
     207        } 
     208 
     209        osync_hashtable_report_deleted(hashtable, ctx, "note"); 
     210 
     211        osync_trace(TRACE_EXIT, "%s", __func__); 
     212        return true; 
    205213} 
    206214