Update change log and spec for wrt-plugins-tizen_0.4.13
[framework/web/wrt-plugins-tizen.git] / src / Messaging / messageDB / MessageStorageReader.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include "MessageStorageReader.h"
19 #include "MsgSqliteWrapper.h"
20
21 #include <dpl/log/log.h>
22 #include <glib.h>
23
24 #define MAX_THREAD_ADDR_LEN     40
25 #define MAX_THREAD_NAME_LEN     195
26 #define MAX_THREAD_DATA_LEN     128
27
28 namespace{
29 //TODO copied from MsgInternalTypes.h
30         typedef unsigned char MSG_MAIN_TYPE_T;
31         typedef unsigned char MSG_SUB_TYPE_T;
32         typedef unsigned char MSG_CLASS_TYPE_T;
33
34         typedef struct
35         {
36                 msg_address_type_t              addressType;                                                                                                    /**< The type of an address in case of an Email or a mobile phone */
37                 msg_recipient_type_t    recipientType;                                                                                                  /**< The type of recipient address in case of To, Cc, and Bcc */
38                 msg_contact_id_t                        contactId;                                                                                                                      /**< The contact ID of address */
39                 char                                                                            addressVal[MAX_ADDRESS_VAL_LEN+1];              /**< The actual value of an address */
40                 char                                                                            displayName[MAX_DISPLAY_NAME_LEN+1];    /**< The display name of an address */
41         } MSG_ADDRESS_INFO_S;
42
43         typedef struct _msg_struct{
44                 int type;
45                 void *data;
46         }msg_struct_s;
47
48         typedef struct
49         {
50                 msg_message_id_t                msgId;                                                                  /**< Indicates the message ID of this message. */
51                 msg_thread_id_t                 threadId;                                                               /**< Indicates the thread ID. */
52                 msg_folder_id_t                 folderId;                                                               /**< Indicates the folder ID. see enum _MSG_FOLDER_TYPE_E */
53                 MSG_MAIN_TYPE_T                 mainType;                                                               /**< Message main type. See enum _MSG_MAIN_TYPE_E */
54                 MSG_SUB_TYPE_T                  subType;                                                                /**< Message sub type. See enum _MSG_SUB_TYPE_E */
55                 MSG_CLASS_TYPE_T                classType;                                                              /**< Message class type. See enum _MSG_CLASS_TYPE_E */
56                 msg_storage_id_t                storageId;                                                              /**< Indicates where the message is saved. see enum _MSG_FOLDER_TYPE_E*/
57                 msg_struct_list_s               *addr_list;
58                 char                                    replyAddress[MAX_PHONE_NUMBER_LEN+1];   /**< Indicates the reply address. */
59                 char                                    subject[MAX_SUBJECT_LEN+1];                                     /**< Indicates the message subject. */
60                 time_t                                  displayTime;                                                                                                    /**< Indicates the display time related to the specific operation. */
61                 msg_network_status_t    networkStatus;                                                  /**< Indicates the network status of the message. */
62                 msg_encode_type_t               encodeType;                                                     /**< Indicates the string encoding type. */
63                 bool                                    bRead;                                                                                                                          /**< Indicates whether the message is read or not. */
64                 bool                                    bProtected;                                                                                                     /**< Indicates whether the message is protected or not. */
65                 bool                                    bBackup;                                                                                                                        /**< Indicates whether the message was restored from PC. */
66                 msg_priority_type_t     priority;                                                               /**< Indicates the priority of the message. */
67                 msg_direction_type_t    direction;                                                              /**< Indicates whether the message is MO or MT, affecting address. */
68                 bool                                    bPortValid;                                                             /**< Indicates whether port information is used or not. */
69                 unsigned short                  dstPort;                                                                /**< Recipient port number, not greater than 16 bit */
70                 unsigned short                  srcPort;                                                                /**< Sender port number, not greater than 16 bit */
71                 int                                     attachCount;                                                                                                    /**< Indicates the count of attached files in mms. */
72                 char                                    thumbPath[MSG_FILEPATH_LEN_MAX+1];
73                 size_t                                  dataSize;                                                                                                                       /**< Indicates the data size. The unit is byte. */
74                 void                                    *pData;                                                                                                                         /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
75                 void                                    *pMmsData;                                                                                                              /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
76 //              size_t                          mmsDataSize;
77         } MSG_MESSAGE_HIDDEN_S;
78
79
80         /**
81          *      @brief  Represents message information for thread view.
82          */
83         typedef struct
84         {
85                 msg_thread_id_t                 threadId;                                                                                                                       /**< Indicates the thread ID of this peer. */
86                 char                                    threadName[MAX_THREAD_NAME_LEN+1];              /**< Indicates the name of this peer. > */
87                 MSG_MAIN_TYPE_T                 mainType;                                                               /**< Indicates the latest msg main type. */
88                 MSG_SUB_TYPE_T                  subType;                                                                /**< Indicates the latest msg sub type. */
89                 char                                    threadData[MAX_THREAD_DATA_LEN+1];              /**< Indicates the latest msg data. */
90                 time_t                                  threadTime;                                                                                                     /**< Indicates the latest msg time. */
91                 msg_direction_type_t    direction;                                                                                                                      /**< Indicates whether the message is MO or MT (affecting address). */
92                 int                                     unreadCnt;                                                                                                              /**< Indicates the unread messages from the Peer. */
93                 int                                     smsCnt;                                                                                                                 /**< Indicates the SMS messages from the Peer. */
94                 int                                     mmsCnt;                                                                                                                 /**< Indicates the MMS messages from the Peer. */
95                 bool                                    bProtected;                                                                                                     /**< Indicates whether the thread includes protected messages.  */
96         } MSG_THREAD_VIEW_S;
97
98         enum _MSG_MAIN_TYPE_E
99         {
100                 MSG_UNKNOWN_TYPE = 0,           /**< Unknown main type */
101                 MSG_SMS_TYPE,                           /**< SMS */
102                 MSG_MMS_TYPE,                           /**< MMS */
103         };
104
105 }//namespace
106
107 enum _MSG_SUB_TYPE_E
108 {
109         /* SMS Specific Message Type */
110         MSG_NORMAL_SMS = 0,                     /**< Text SMS message */
111         MSG_CB_SMS,                                     /**< Cell Broadcasting  message */
112         MSG_JAVACB_SMS,                         /**< JAVA Cell Broadcasting  message */
113         MSG_TYPE0_SMS,                                  /**< Short Message Type 0 */
114         MSG_REPLACE_TYPE1_SMS,          /**< Replace Short Message Type 1 */
115         MSG_REPLACE_TYPE2_SMS,          /**< Replace Short Message Type 2 */
116         MSG_REPLACE_TYPE3_SMS,          /**< Replace Short Message Type 3 */
117         MSG_REPLACE_TYPE4_SMS,          /**< Replace Short Message Type 4 */
118         MSG_REPLACE_TYPE5_SMS,          /**< Replace Short Message Type 5 */
119         MSG_REPLACE_TYPE6_SMS,          /**< Replace Short Message Type 6 */
120         MSG_REPLACE_TYPE7_SMS,          /**< Replace Short Message Type 7 */
121         MSG_WAP_SI_SMS,                         /**< WAP Push Message SI */
122         MSG_WAP_SL_SMS,                         /**< WAP Push Message SL */
123         MSG_WAP_CO_SMS,                         /**< WAP Push Message CO */
124         MSG_MWI_VOICE_SMS,                      /**< MWI Message Voice */
125         MSG_MWI_FAX_SMS,                                /**< MWI Message Fax */
126         MSG_MWI_EMAIL_SMS,                      /**< MWI Message Email */
127         MSG_MWI_OTHER_SMS,                      /**< MWI Message Other */
128         MSG_STATUS_REPORT_SMS,          /**< SMS-STATUS-REPORT */
129         MSG_SYNCML_CP,                          /**< SyncML Message CP */
130         MSG_LBS_SMS,                                    /**< LBS Message */
131         MSG_REJECT_SMS,                         /**< Reject Message */
132         MSG_CONCAT_SIM_SMS,                     /**< Concatenated Message in SIM */
133
134         /* MMS Specific Message Type */
135         MSG_SENDREQ_MMS = 24,                                   /**< MMS Send Request message */
136         MSG_SENDCONF_MMS,                               /**< MMS Send Confirm message */
137         MSG_NOTIFICATIONIND_MMS,                        /**< MMS Notification Indication message */
138         MSG_GET_MMS,                                            /**< MMS GET MMS message */
139         MSG_NOTIFYRESPIND_MMS,                  /**< MMS Notify Response Indication message */
140         MSG_RETRIEVE_MMS,                                       /**< MMS Retrive MMS message */
141         MSG_RETRIEVE_AUTOCONF_MMS,              /**< MMS Retrieve Confirm message by auto retrieving*/
142         MSG_RETRIEVE_MANUALCONF_MMS,    /**< MMS Retrieve Confirm message by manual retrieving*/
143         MSG_ACKNOWLEGEIND_MMS,                  /**< MMS Acknowledge Indication message */
144         MSG_DELIVERYIND_MMS,                            /**< MMS Delivery Indication message */
145         MSG_READRECIND_MMS,                             /**< MMS Read Receive Indication message */
146         MSG_READORGIND_MMS,                             /**< MMS Read Origin Indication message */
147         MSG_FORWARD_MMS,                                        /**< MMS Forward message */
148         MSG_FORWARDREQ_MMS,                             /**< MMS Forward Request message */
149         MSG_FORWARDCONF_MMS,                    /**< MMS Forward Confirm message */
150         MSG_READREPLY_MMS,                              /**< MMS Read Reply message */
151         MSG_SENDREQ_JAVA_MMS,                   /**< MMS Send Request message for JAVA MMS */
152
153         MSG_ETWS_SMS,
154 };
155
156
157
158 MessageStorageReader::MessageStorageReader() {
159         // TODO Auto-generated constructor stub
160
161 }
162
163 MessageStorageReader::~MessageStorageReader() {
164         // TODO Auto-generated destructor stub
165 }
166
167 msg_error_t MessageStorageReader::MsgStoConnectDB(){
168         return MSG_SUCCESS;
169 }
170
171 msg_error_t MessageStorageReader::MsgStoDisconnectDB(){
172         if (dbHandle.disconnect() != MSG_SUCCESS){
173                 LogError(">>>[ERROR] DB Disconnect Fail");
174                 return MSG_ERR_DB_DISCONNECT;
175         }
176
177         LogDebug(">>>");
178
179         return MSG_SUCCESS;
180 }
181
182
183 // MsgStoSearchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, msg_struct_list_s *pMsgList)
184 int MessageStorageReader::queryMessage(const std::string& whereClause, const std::string& orderLimit, /*out*/msg_struct_list_s *pMsgList){
185         LogDebug("<<< whereClause:[" << whereClause << "]");
186
187         // Clear Out Parameter
188         pMsgList->nCount = 0;
189         pMsgList->msg_struct_info = NULL;
190
191         int rowCnt = 0;
192         int index = 26; // numbers of index
193
194         char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
195         char displayName[MAX_DISPLAY_NAME_LEN+1];
196
197         std::ostringstream oStream;
198         std::string stringSqlQuery;
199         std::string tmpWhereClause;     
200
201         // Get Name Order
202 //      int order = MsgGetContactNameOrder();
203         int order = 0;
204
205                 oStream << "SELECT A.MSG_ID, A.CONV_ID, A.FOLDER_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, \
206 A.DISPLAY_TIME, A.DATA_SIZE, A.NETWORK_STATUS, A.READ_STATUS, A.PROTECTED, A.BACKUP, A.PRIORITY, \
207 A.MSG_DIRECTION, A.SCHEDULED_TIME, A.SUBJECT, A.MSG_TEXT, B.ADDRESS_TYPE, B.RECIPIENT_TYPE, \
208 B.CONTACT_ID, B.ADDRESS_VAL, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME, A.ATTACHMENT_COUNT, A.THUMB_PATH \
209 FROM " << MSGFW_MESSAGE_TABLE_NAME << " A, " << MSGFW_ADDRESS_TABLE_NAME << " B ";
210
211
212         if(whereClause.length()==0){
213                 tmpWhereClause.append("WHERE ");
214         }else{
215                 tmpWhereClause.append(whereClause);
216                 tmpWhereClause.append(" ");
217                 tmpWhereClause.append("AND ");
218         }
219
220         tmpWhereClause.append("(A.CONV_ID = B.CONV_ID AND B.ADDRESS_ID <> 0) ");
221
222         if(orderLimit.length() == 0)
223         {
224                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
225         }
226         else
227         {
228                 tmpWhereClause.append(orderLimit);
229                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
230         }
231         LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
232
233
234         oStream << tmpWhereClause;
235         stringSqlQuery = oStream.str();
236
237         LogDebug("stringSqlQuery:[" << stringSqlQuery << "]");
238         msg_error_t err = dbHandle.getTable(stringSqlQuery.c_str(), &rowCnt);
239
240         if (err == MSG_ERR_DB_NORECORD) {
241                 LogDebug("MSG_ERR_DB_NORECORD");                
242                 dbHandle.freeTable();
243
244                 return MSG_SUCCESS;
245         } else if (err != MSG_SUCCESS) {
246                 LogDebug("Get table fail. "<< stringSqlQuery);
247
248                 dbHandle.freeTable();
249
250                 return err;
251         }
252         
253         pMsgList->nCount = rowCnt;
254
255         LogDebug("pMsgList->nCount ="<<  pMsgList->nCount);
256
257         pMsgList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * rowCnt];
258
259         MSG_MESSAGE_HIDDEN_S *pTmp = NULL;
260         msg_struct_s *msg = NULL;
261
262         for (int i = 0; i < rowCnt; i++) {
263                 pMsgList->msg_struct_info[i] = (msg_struct_t)new msg_struct_s;
264
265                 msg = (msg_struct_s *)pMsgList->msg_struct_info[i];
266
267                 msg->type = MSG_STRUCT_MESSAGE_INFO;
268                 msg->data = (int *)new char[sizeof(MSG_MESSAGE_HIDDEN_S)];
269
270                 pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data;
271
272                 memset(pTmp, 0x00, sizeof(MSG_MESSAGE_HIDDEN_S));
273
274                 pTmp->pData = NULL;
275                 pTmp->pMmsData = NULL;
276
277                 pTmp->msgId = dbHandle.getColumnToInt(index++);
278                 pTmp->threadId = dbHandle.getColumnToInt(index++);
279                 pTmp->folderId = dbHandle.getColumnToInt(index++);
280                 pTmp->storageId = dbHandle.getColumnToInt(index++);
281                 pTmp->mainType = dbHandle.getColumnToInt(index++);
282                 pTmp->subType = dbHandle.getColumnToInt(index++);
283                 pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++);
284                 pTmp->dataSize = dbHandle.getColumnToInt(index++);
285                 pTmp->networkStatus = dbHandle.getColumnToInt(index++);
286                 pTmp->bRead = dbHandle.getColumnToInt(index++);
287                 pTmp->bProtected = dbHandle.getColumnToInt(index++);
288                 pTmp->bBackup = dbHandle.getColumnToInt(index++);
289                 pTmp->priority = dbHandle.getColumnToInt(index++);
290                 pTmp->direction= dbHandle.getColumnToInt(index++);
291                 index++; // This field is reserved.
292
293                 dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject);
294
295                 if (pTmp->mainType == MSG_MMS_TYPE &&
296                         (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->subType == MSG_NOTIFICATIONIND_MMS)) {
297                         pTmp->pData = NULL;
298                         index++;
299                 } else {
300                         LogDebug("pTmp->dataSize = "<< pTmp->dataSize);
301                         pTmp->pData = (void *)new char[pTmp->dataSize + 2];
302                         memset(pTmp->pData, 0x00, pTmp->dataSize + 2);
303
304                         dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData);
305                 }
306
307                 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
308                 msg_struct_s *addr_info = NULL;
309                 MSG_ADDRESS_INFO_S *address = NULL;
310
311                 addr_list->nCount = 1;
312                 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t *)*MAX_TO_ADDRESS_CNT];
313
314                 msg_struct_s *pTmpAddr = NULL;
315
316                 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
317                         addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
318                         pTmpAddr = (msg_struct_s *)addr_list->msg_struct_info[i];
319                         pTmpAddr->type = MSG_STRUCT_ADDRESS_INFO;
320                         pTmpAddr->data = new MSG_ADDRESS_INFO_S;
321                         memset(pTmpAddr->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
322
323                         addr_list->msg_struct_info[i] = (msg_struct_t)pTmpAddr;
324                 }
325
326                 addr_info = (msg_struct_s *)addr_list->msg_struct_info[0];
327                 address = (MSG_ADDRESS_INFO_S *)addr_info->data;
328                 address->addressType = dbHandle.getColumnToInt(index++);
329                 address->recipientType = dbHandle.getColumnToInt(index++);
330                 address->contactId = dbHandle.getColumnToInt(index++);
331
332                 dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, address->addressVal);
333
334                 memset(displayName, 0x00, sizeof(displayName));
335                 dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, displayName);
336
337                 memset(firstName, 0x00, sizeof(firstName));
338                 dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, firstName);
339
340                 memset(lastName, 0x00, sizeof(lastName));
341                 dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, lastName);
342
343                 if (strlen(displayName) <= 0) {
344                         if (order == 0) {
345                                 if (firstName[0] != '\0') {
346                                         strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
347                                 }
348
349                                 if (lastName[0] != '\0') {
350                                         strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
351                                         strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
352                                 }
353                         }
354 /*
355                         else if (order == 1) {
356                                 if (lastName[0] != '\0') {
357                                         strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
358                                         strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
359                                 }
360
361                                 if (firstName[0] != '\0') {
362                                         strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
363                                 }
364                         }
365 */
366                 }
367
368                 strncpy(address->displayName, displayName, MAX_DISPLAY_NAME_LEN);
369
370                 pTmp->addr_list = addr_list;
371
372                 pTmp->attachCount = dbHandle.getColumnToInt(index++);
373
374                 dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath);
375
376         }
377         dbHandle.freeTable();
378
379         LogDebug(">>>");
380         return MSG_SUCCESS;
381 }
382
383 //msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList)
384 int MessageStorageReader::queryConversation(const std::string& whereClause, const std::string& orderLimit,
385         msg_struct_list_s *pThreadViewList){
386
387         pThreadViewList->nCount = 0;
388         pThreadViewList->msg_struct_info = NULL;
389
390         int rowCnt = 0;
391         int index = 10; // numbers of index
392
393         std::ostringstream oStream;
394         std::string stringSqlQuery;
395
396         std::string tmpWhereClause;
397         LogDebug("<<< whereClause:[" << whereClause << "]");
398         if(whereClause.length()==0){
399                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");              
400                 tmpWhereClause.append("WHERE (B.SMS_CNT > 0 OR B.MMS_CNT > 0) AND A.CONV_ID = B.CONV_ID ");
401                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");                      
402         }else{
403                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");      
404                 tmpWhereClause.append(whereClause);
405                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");      
406         }
407
408         if(orderLimit.length() == 0)
409         {
410                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
411         }
412         else
413         {
414                 tmpWhereClause.append(orderLimit);
415                 LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
416         }
417
418         oStream << "SELECT B.CONV_ID, B.UNREAD_CNT, B.SMS_CNT, B.MMS_CNT, \
419 B.MAIN_TYPE, B.SUB_TYPE, B.MSG_DIRECTION, B.DISPLAY_TIME, B.DISPLAY_NAME, B.MSG_TEXT \
420 FROM " << MSGFW_ADDRESS_TABLE_NAME << " A, "  << MSGFW_CONVERSATION_TABLE_NAME  << " B ";
421
422         oStream << tmpWhereClause;
423         stringSqlQuery = oStream.str();
424         LogDebug("stringSqlQuery:[" << stringSqlQuery << "]");
425
426         msg_error_t err = dbHandle.getTable(stringSqlQuery.c_str(), &rowCnt);
427
428         if (err == MSG_ERR_DB_NORECORD) {
429                 dbHandle.freeTable();
430                 return MSG_SUCCESS;
431         } else if (err != MSG_SUCCESS) {
432                 LogDebug("stringSqlQuery:[" << stringSqlQuery << "]");
433                 dbHandle.freeTable();
434                 return err;
435         }
436
437         if (rowCnt < 1) {
438                 LogDebug("rowCnt is %d"<< rowCnt);
439                 dbHandle.freeTable();
440                 return err;
441         }
442
443         pThreadViewList->nCount = rowCnt;
444
445         LogDebug("pThreadViewList->nCount [" << pThreadViewList->nCount << "]");
446
447         pThreadViewList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t)*rowCnt];
448
449         MSG_THREAD_VIEW_S *pTmp = NULL;
450         msg_struct_s *thread_t = NULL;
451
452         for (int i = 0; i < rowCnt; i++) {
453                 thread_t = (msg_struct_s *)new msg_struct_s;
454                 pThreadViewList->msg_struct_info[i] = (msg_struct_t)thread_t;
455
456                 thread_t->type = MSG_STRUCT_THREAD_INFO;
457                 thread_t->data = new MSG_THREAD_VIEW_S;
458
459                 pTmp = (MSG_THREAD_VIEW_S *)thread_t->data;
460                 memset(pTmp, 0x00, sizeof(MSG_THREAD_VIEW_S));
461
462                 pTmp->threadId = dbHandle.getColumnToInt(index++);
463
464                 pTmp->unreadCnt = dbHandle.getColumnToInt(index++);
465                 pTmp->smsCnt = dbHandle.getColumnToInt(index++);
466                 pTmp->mmsCnt = dbHandle.getColumnToInt(index++);
467
468                 pTmp->mainType = dbHandle.getColumnToInt(index++);
469                 pTmp->subType = dbHandle.getColumnToInt(index++);
470
471                 pTmp->direction = dbHandle.getColumnToInt(index++);
472                 pTmp->threadTime = (time_t)dbHandle.getColumnToInt(index++);
473
474                 memset(pTmp->threadName, 0x00, sizeof(pTmp->threadName));
475                 dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, pTmp->threadName);
476
477                 memset(pTmp->threadData, 0x00, sizeof(pTmp->threadData));
478                 dbHandle.getColumnToString(index++, MAX_THREAD_DATA_LEN, pTmp->threadData);
479         }
480
481         dbHandle.freeTable();
482
483         return MSG_SUCCESS;
484 }
485