update tizen source
[framework/messaging/msg-service.git] / plugin / sms_plugin / SmsPluginUAManager.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #include "MsgDebug.h"
32 #include "MsgCppTypes.h"
33 #include "MsgException.h"
34 #include "SmsPluginEventHandler.h"
35 #include "SmsPluginWapPushHandler.h"
36 #include "SmsPluginConcatHandler.h"
37 #include "SmsPluginTransport.h"
38 #include "SmsPluginUAManager.h"
39
40
41 /*==================================================================================================
42                                      IMPLEMENTATION OF SmsPluginUAManager - Member Functions
43 ==================================================================================================*/
44 SmsPluginUAManager* SmsPluginUAManager::pInstance = NULL;
45
46
47 SmsPluginUAManager::SmsPluginUAManager() : mx(), cv()
48 {
49         start();
50 }
51
52
53 SmsPluginUAManager::~SmsPluginUAManager()
54 {
55
56 }
57
58
59 SmsPluginUAManager* SmsPluginUAManager::instance()
60 {
61         if (!pInstance)
62                 pInstance = new SmsPluginUAManager();
63
64         return pInstance;
65 }
66
67
68 void SmsPluginUAManager::run()
69 {
70         while (1)
71         {
72                 if (smsTranQ.empty())
73                         cv.wait(mx.pMutex());
74
75                 SMS_REQUEST_INFO_S request;
76                 smsTranQ.front(&request);
77
78                 try
79                 {
80                         SmsPluginTransport::instance()->submitRequest(&request);
81                 }
82                 catch (MsgException& e)
83                 {
84                         MSG_FATAL("%s", e.what());
85
86                         smsTranQ.pop_front();
87                         continue;
88                 }
89                 catch (exception& e)
90                 {
91                         MSG_FATAL("%s", e.what());
92
93                         smsTranQ.pop_front();
94                         continue;
95                 }
96
97                 smsTranQ.pop_front();
98         }
99 }
100
101
102 void SmsPluginUAManager::addReqEntity(SMS_REQUEST_INFO_S request)
103 {
104         smsTranQ.push_back(request);
105         cv.signal();
106 }
107