RSA sync with private
[platform/core/messaging/msg-service.git] / plugin / sms_plugin / SmsPluginUAManager.cpp
1 /*
2 * Copyright 2012  Samsung Electronics Co., Ltd
3 *
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *    http://www.tizenopensource.org/license
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "MsgDebug.h"
18 #include "MsgCppTypes.h"
19 #include "MsgException.h"
20 #include "SmsPluginEventHandler.h"
21 #include "SmsPluginWapPushHandler.h"
22 #include "SmsPluginConcatHandler.h"
23 #include "SmsPluginTransport.h"
24 #include "SmsPluginUAManager.h"
25
26
27 /*==================================================================================================
28                                      IMPLEMENTATION OF SmsPluginUAManager - Member Functions
29 ==================================================================================================*/
30 SmsPluginUAManager* SmsPluginUAManager::pInstance = NULL;
31
32
33 SmsPluginUAManager::SmsPluginUAManager() : mx(), cv()
34 {
35         start();
36 }
37
38
39 SmsPluginUAManager::~SmsPluginUAManager()
40 {
41
42 }
43
44
45 SmsPluginUAManager* SmsPluginUAManager::instance()
46 {
47         if (!pInstance)
48                 pInstance = new SmsPluginUAManager();
49
50         return pInstance;
51 }
52
53
54 void SmsPluginUAManager::run()
55 {
56         while (1)
57         {
58                 if (smsTranQ.empty())
59                         cv.wait(mx.pMutex());
60
61                 SMS_REQUEST_INFO_S request;
62                 smsTranQ.front(&request);
63
64                 try
65                 {
66                         SmsPluginTransport::instance()->submitRequest(&request);
67                 }
68                 catch (MsgException& e)
69                 {
70                         MSG_FATAL("%s", e.what());
71
72                         smsTranQ.pop_front();
73                         continue;
74                 }
75                 catch (exception& e)
76                 {
77                         MSG_FATAL("%s", e.what());
78
79                         smsTranQ.pop_front();
80                         continue;
81                 }
82
83                 smsTranQ.pop_front();
84         }
85 }
86
87
88 void SmsPluginUAManager::addReqEntity(SMS_REQUEST_INFO_S *request)
89 {
90         SMS_REQUEST_INFO_S reqTmp = {0,};
91
92         memcpy(&reqTmp, request, sizeof(SMS_REQUEST_INFO_S));
93         smsTranQ.push_back(reqTmp);
94         cv.signal();
95 }
96