+ ms_free(peer);\r
+}\r
+\r
+int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr){\r
+ LinphoneCore *lc=linphone_chat_room_get_lc(cr);\r
+ int numrows=0;\r
+ \r
+ if (lc->db==NULL) return 0;\r
+ \r
+ char *peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));\r
+ char *buf=sqlite3_mprintf("select count(*) from history where remoteContact = %Q and read = 0;",peer);\r
+ sqlite3_stmt *selectStatement;\r
+ int returnValue = sqlite3_prepare_v2(lc->db,buf,-1,&selectStatement,NULL);\r
+ if (returnValue == SQLITE_OK){\r
+ if(sqlite3_step(selectStatement) == SQLITE_ROW){\r
+ numrows= sqlite3_column_int(selectStatement, 0);\r
+ }\r
+ }\r
+ sqlite3_finalize(selectStatement);\r
+ sqlite3_free(buf);\r
+ ms_free(peer);\r
+ return numrows;\r