summaryrefslogtreecommitdiff
path: root/test/messages_search_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/messages_search_test.c')
-rwxr-xr-x[-rw-r--r--]test/messages_search_test.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/test/messages_search_test.c b/test/messages_search_test.c
index 5bca8bc..25300fd 100644..100755
--- a/test/messages_search_test.c
+++ b/test/messages_search_test.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <dlog.h>
#include <messages.h>
@@ -9,6 +10,7 @@ bool _search_cb(messages_message_h msg, int index, int result_count, int total_c
messages_message_type_e msgType;
messages_message_box_e mbox;
int ret;
+ int cnt;
char *text;
int i, nAddr;
char *addr = NULL;
@@ -16,41 +18,48 @@ bool _search_cb(messages_message_h msg, int index, int result_count, int total_c
messages_get_message_type(msg, &msgType);
- printf("=[%d/%d]==================================\n", index + 1, result_count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "=[%d/%d]==================================\n", index + 1, result_count);
messages_get_address_count(msg, &nAddr);
for (i=0; i < nAddr; i++) {
ret = messages_get_address(msg, i, &addr, NULL);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Address[%d]: %s\n", i, addr);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Address[%d]: %s\n", i, addr);
free(addr);
}
}
ret = messages_get_text(msg, &text);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Text: %s\n", text);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Text: %s\n", text);
free(text);
}
if (MESSAGES_TYPE_SMS == msgType) {
- printf("Type: SMS\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: SMS\n");
} else if (MESSAGES_TYPE_MMS == msgType) {
- printf("Type: MMS\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: MMS\n");
ret = messages_mms_get_subject(msg, &text);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Subject: %s\n", text);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Subject: %s\n", text);
free(text);
}
+
+ ret = messages_mms_get_attachment_count(msg, &cnt);
+ if (MESSAGES_ERROR_NONE == ret) {
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Attachments: %d\n", cnt);
+ }
} else {
- printf("Type: Unknown");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: Unknown");
}
ret = messages_get_time(msg, &time);
- printf("Time: %d, %s", (int)time, ctime(&time));
+ char buf[50];
+ if (ctime_r(&time, buf))
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Time: %d, %s", (int)time, ctime_r(&time, buf));
ret = messages_get_mbox_type(msg, &mbox);
- printf("MBOX: %d\n", mbox);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "MBOX: %d\n", mbox);
return true;
@@ -66,7 +75,7 @@ int main(int argc, char *argv[])
// open service
ret = messages_open_service(&svc);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_open_service() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_open_service() = %d", ret);
return 1;
}
@@ -75,19 +84,19 @@ int main(int argc, char *argv[])
NULL, NULL,
0, 0, _search_cb, NULL);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_foreach_message_from_db() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_foreach_message_from_db() = %d", ret);
return 1;
}
- printf("===============================================\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "===============================================\n");
ret = messages_get_message_count(svc, MESSAGES_MBOX_INBOX, MESSAGES_TYPE_SMS, &count);
- printf("INBOX: %d messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "INBOX: %d messages\n", count);
ret = messages_get_message_count(svc, MESSAGES_MBOX_SENTBOX, MESSAGES_TYPE_SMS, &count);
- printf("SENTBOX: %d messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "SENTBOX: %d messages\n", count);
ret = messages_get_message_count(svc, MESSAGES_MBOX_OUTBOX, MESSAGES_TYPE_SMS, &count);
- printf("OUTBOX: %d sms messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "OUTBOX: %d sms messages\n", count);
ret = messages_get_message_count(svc, MESSAGES_MBOX_OUTBOX, MESSAGES_TYPE_MMS, &count);
- printf("OUTBOX: %d mms messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "OUTBOX: %d mms messages\n", count);