[meego-commits] 6381: Changes to Trunk:Handset/smshistory

raji rajyalakshmi.bommaraju at intel.com
Mon Aug 9 21:39:50 UTC 2010


Hi,
I have made the following changes to smshistory in project Trunk:Handset. Please review and accept ASAP.

Thank You,
raji

[This message was auto-generated]

---

Request #6381:

  submit:   devel:ux:handset/smshistory(r7) -> Trunk:Handset/smshistory


Message:
    Fix for BMC#5006

State:   new          2010-08-09T09:31:28 raji
Comment: None



changes files:
--------------
--- smshistory.changes
+++ smshistory.changes
@@ -0,0 +1,3 @@
+* Mon Aug 09 2010 Raji Bommaraju <Rajyalakshmi.Bommaraju at intel.com> - 0.1.5
+Fix for BMC# 5006, Added code to accept acknowledgements only if it is expectingthem, modified code to send history_changed signals when new record is added to storage.These two changes will fix the messages going out of sync. 
+

old:
----
  smshistory-0.1.4.tar.bz2

new:
----
  smshistory-0.1.5.tar.bz2

spec files:
-----------
--- smshistory.spec
+++ smshistory.spec
@@ -7,7 +7,7 @@
 
 Name:       smshistory
 Summary:    sms history logging plugin for ofono
-Version:    0.1.4
+Version:    0.1.5
 Release:    1
 Group:      Applications/System
 License:    GPLv2

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

++++++ smshistory-0.1.4.tar.bz2 -> smshistory-0.1.5.tar.bz2
--- configure.ac
+++ configure.ac
@@ -2,7 +2,7 @@
 
 m4_define(smshistory_version_major, 0)
 m4_define(smshistory_version_minor, 1)
-m4_define(smshistory_version_micro, 4)
+m4_define(smshistory_version_micro, 5)
 
 m4_define([smshistory_version],
           [smshistory_version_major.smshistory_version_minor.smshistory_version_micro])
--- src/history_plugin.c
+++ src/history_plugin.c
@@ -114,6 +114,7 @@
         GHashTable *msghash;
 	int temp_unread;
 	int temp_tail;
+        int ack_guard;
 } SharedData;
 
 static SharedData *shared = NULL;
@@ -237,6 +238,29 @@
              
 }
 
+void print_record(SmsHistory *data)
+{
+
+        struct tm tmstart, tmend;
+        char sttime[128], endtime[128]; 
+       	localtime_r(&(data->starttime), &tmstart); 
+    	strftime(sttime, 127, "%a, %d %b %Y %H:%M:%S %z", &tmstart);
+    	sttime[127] = '\0';
+
+       	localtime_r(&(data->endtime), &tmend); 
+	strftime(endtime, 127, "%a, %d %b %Y %H:%M:%S %z", &tmend);
+    	endtime[127] = '\0';
+
+	ofono_debug("single record id: %d\tlineid: %s\type: %d\tsttime: %s\tendtime: %s\t mesg leng: %d\n",
+                                                           data->msgid,
+                                                           data->lineid,
+                                                           data->calltype,
+                                                           sttime,
+                                                           endtime,
+                                                           data->msgsize);
+
+}
+
 int init_header(void *dataPtr)
 {
 	sem_wait(&(shared->mutex));
@@ -267,6 +291,7 @@
 	int historyFile;
 	struct stat statbuf;
 	DIR *dirptr;
+        shared->ack_guard=0;
 	if (! (dirptr = opendir(HISTORY_FILE_PATH)) ){
 		ofono_debug("%s: doesnt exist",HISTORY_FILE_PATH);
 
@@ -415,6 +440,7 @@
         	//delete if msg file on disk 
                 SmsHistory recp;
 		memcpy(&recp, writeMap, RECORD_SIZE);
+                print_record(&recp);
         	if (recp.msgsize > MSG_LEN){ 
 			ofono_debug("deleting: %d",recp.msgid);
        			delete_file(recp.msgid);
@@ -465,8 +491,7 @@
 	msync (shared->dataMap, TOTAL_SIZE, MS_ASYNC); 
 	sem_post(&(shared->mutex));
         
-	if (unread > 0)
-        	emit_sms_history_changed(unread);
+       	emit_sms_history_changed(unread);
     	
 }
 
@@ -534,6 +559,7 @@
 		// update memory with the info
 		SmsHistory smsrec;
 
+
 		if (shared->msghash){
               		int  value = GPOINTER_TO_INT(
 					g_hash_table_lookup(shared->msghash,
@@ -560,8 +586,8 @@
 			// send dbus-signal
 			ofono_debug("send status update");
 		}
-			//send signal what ever happens  
-			emit_sms_status_changed(smsrec.msgid,
+		//send signal even if we going to fail to update disk file  
+		emit_sms_status_changed(smsrec.msgid,
                                                 smsrec.status,
                                                 smsrec.endtime);
 
@@ -718,19 +744,34 @@
 
 	dbus_message_iter_init_append(reply, &iter);
 
+        
 	sem_wait(&(shared->mutex));
-	(shared->header).unread = (shared->header).unread - shared->temp_unread;
-        (shared->header).tail = shared->temp_tail;
+     
+        // This check protects from duplicate acks 
+	if(shared->ack_guard > 0)
+        { 
+			ofono_debug("set_smsistory_read: temp_unread = %d,unread=%d\n",shared->temp_unread,(shared->header).unread);
+		shared->ack_guard -= 1;
+                // protects from going to negative number
+                if ((shared->header).unread >= shared->temp_unread)
+                {
+			(shared->header).unread = (shared->header).unread - shared->temp_unread;
+			(shared->header).tail = shared->temp_tail;
  
-	//sync header 
-	memcpy(shared->dataMap,&(shared->header),HEADER_SIZE);
+			//sync header 
+			memcpy(shared->dataMap,&(shared->header),HEADER_SIZE);
 
-        ofono_debug ("updating tail: %d",(shared->header).tail);
+			ofono_debug ("updating tail: %d",(shared->header).tail);
 
-	sem_post(&(shared->mutex));
+			sem_post(&(shared->mutex));
 
-	msync((shared->dataMap),TOTAL_SIZE, MS_ASYNC);
+			msync((shared->dataMap),TOTAL_SIZE, MS_ASYNC);
+			return reply;
 
+
+		}                
+       }
+	sem_post(&(shared->mutex));
 	return reply;
 }
 
@@ -859,6 +900,7 @@
 
 		sem_wait(&(shared->mutex));
 		shared->temp_unread = unread;
+                ofono_debug("read_all_data: setting temp_unread=%d\n",unread);
 		sem_post(&(shared->mutex));
 
 		*allrecs = g_slist_prepend(*allrecs,(gpointer) data);
@@ -944,6 +986,9 @@
 		alldata = g_slist_next(alldata);                  
 	}
 
+	sem_wait(&(shared->mutex));
+	shared->ack_guard = shared->ack_guard +1;
+	sem_post(&(shared->mutex));
    	dbus_message_iter_close_container(&iter,&array);
    	return reply;
 }

++++++ smshistory.yaml
--- smshistory.yaml
+++ smshistory.yaml
@@ -1,6 +1,6 @@
 Name: smshistory
 Summary: sms history logging plugin for ofono
-Version: 0.1.4
+Version: 0.1.5
 Release: 1
 Group: Applications/System
 License: GPLv2



More information about the MeeGo-commits mailing list