I have made the following changes intended for :
  nemo:devel:mw / libcommhistory

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.merproject.org//request/show/158

Thank You,
John Brooks

[This message was auto-generated]

---

Request # 158:

Messages from BOSS:

State: review at 2013-04-03T04:34:08 by cibot

Reviews:
       accepted by cibot : Prechecks succeeded.
       new for nemo:devel:mw : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:jbrooks:branches:nemo:devel:mw / libcommhistory -> nemo:devel:mw 
/ libcommhistory
  
changes files:
--------------
--- libcommhistory.changes
+++ libcommhistory.changes
@@ -0,0 +1,4 @@
+* Tue Apr 02 2013 John Brooks <[email protected]> - 1.5.2
+- Fix recreateIds query not always returning the highest numeric ID
+- Add methods to delete groups from GroupObject and ContactGroup
+

old:
----
  libcommhistory-1.5.1.tar.bz2

new:
----
  libcommhistory-1.5.2.tar.bz2

spec files:
-----------
--- libcommhistory.spec
+++ libcommhistory.spec
@@ -1,6 +1,6 @@
 Name:       libcommhistory
 Summary:    Communications event history database API
-Version:    1.5.1
+Version:    1.5.2
 Release:    1
 Group:      System/Libraries
 License:    LGPL

other changes:
--------------

++++++ libcommhistory-1.5.1.tar.bz2 -> libcommhistory-1.5.2.tar.bz2
--- src/contactgroup.cpp
+++ src/contactgroup.cpp
@@ -24,6 +24,7 @@
 #include "trackerio.h"
 #include "updatesemitter.h"
 #include "commonutils.h"
+#include "committingtransaction.h"
 
 namespace CommHistory {
 
@@ -345,6 +346,34 @@
     return true;
 }
 
+bool ContactGroup::deleteGroups()
+{
+    Q_D(ContactGroup);
+
+    QList<int> ids;
+    ids.reserve(d->groups.size());
+    foreach (GroupObject *group, d->groups)
+        ids.append(group->id());
+
+    if (ids.isEmpty())
+        return true;
+
+    TrackerIO *tracker = TrackerIO::instance();
+    tracker->transaction();
+
+    if (!tracker->deleteGroups(ids, true, 0)) {
+        tracker->rollback();
+        return false;
+    }
+
+    CommittingTransaction *t = tracker->commit();
+
+    if (t)
+        t->addSignal(false, UpdatesEmitter::instance().data(), 
"groupsDeleted", Q_ARG(QList<int>, ids));
+
+    return t != 0;
+}
+
 GroupObject *ContactGroup::findGroup(const QString &localUid, const QString 
&remoteUid)
 {
     Q_D(ContactGroup);
--- src/contactgroup.h
+++ src/contactgroup.h
@@ -98,6 +98,7 @@
     void updateGroup(GroupObject *group);
 
     bool markAsRead();
+    bool deleteGroups();
 
 signals:
     void contactsChanged();
--- src/groupobject.cpp
+++ src/groupobject.cpp
@@ -435,6 +435,16 @@
     return d->manager->markAsReadGroup(id());
 }
 
+bool GroupObject::deleteGroup()
+{
+    if (!d->manager) {
+        qDebug() << Q_FUNC_INFO << "No manager for object instance";
+        return false;
+    }
+
+    return d->manager->deleteGroups(QList<int>() << id(), true);
+}
+
 QString GroupObject::toString() const
 {
     QString contacts;
--- src/groupobject.h
+++ src/groupobject.h
@@ -90,6 +90,11 @@
     Q_INVOKABLE bool markAsRead();
 
     /*!
+     * Delete the group and all its messages
+     */
+    Q_INVOKABLE bool deleteGroup();
+
+    /*!
      * Object contains a valid group
      */
     bool isValid() const;
--- src/trackerio.cpp
+++ src/trackerio.cpp
@@ -1094,8 +1094,9 @@
     qDebug() << Q_FUNC_INFO;
 
     // Read max event/group ids from tracker and reset IdSource.
+    // There is apparently no way to extract the integer and sort by that with 
sparql.
 
-    QSparqlQuery query("SELECT ?m { ?m a nmo:Message. FILTER(REGEX(?m, 
\"^(message|call):\")) } ORDER BY DESC(tracker:id(?m)) LIMIT 1");
+    QSparqlQuery query("SELECT ?m { ?m a nmo:Message. FILTER(REGEX(?m, 
\"^(message|call):\")) }");
     QSparqlResult *result = d->connection().syncExec(query);
     if (result->hasError()) {
         qCritical() << Q_FUNC_INFO << "Error querying message ids";
@@ -1106,14 +1107,16 @@
     int maxMessageId = 0;
     int len = QString(QLatin1String("message:")).length();
     if (result->first()) {
-        bool ok = false;
-        int id = result->value(0).toString().mid(len).toInt(&ok);
-        if (ok)
-            maxMessageId = id;
+        do {
+            bool ok = false;
+            int id = result->value(0).toString().mid(len).toInt(&ok);
+            if (ok && id > maxMessageId)
+                maxMessageId = id;
+        } while (result->next());
     }
     delete result;
 
-    QSparqlQuery groupQuery("SELECT ?c { ?c a nmo:CommunicationChannel. 
FILTER(REGEX(?c, \"^conversation:\")) } ORDER BY DESC(tracker:id(?c)) LIMIT 1");
+    QSparqlQuery groupQuery("SELECT ?c { ?c a nmo:CommunicationChannel. 
FILTER(REGEX(?c, \"^conversation:\")) }");
     result = d->connection().syncExec(groupQuery);
     if (result->hasError()) {
         qCritical() << Q_FUNC_INFO << "Error querying group ids";
@@ -1124,10 +1127,12 @@
     int maxGroupId = 0;
     len = QString(QLatin1String("conversation:")).length();
     if (result->first()) {
-        bool ok = false;
-        int id = result->value(0).toString().mid(len).toInt(&ok);
-        if (ok)
-            maxGroupId = id;
+        do {
+            bool ok = false;
+            int id = result->value(0).toString().mid(len).toInt(&ok);
+            if (ok && id > maxGroupId)
+                maxGroupId = id;
+        } while (result->next());
     }
     delete result;
 



Reply via email to