Camera issue.
[apps/native/sample/QrCodeRecognizer.git] / project / src / ControlManager.cpp
1 //
2 // Tizen Native SDK
3 // Open Service Platform
4 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // All rights reserved.
6 //
7 // This software contains confidential and proprietary information
8 // of Samsung Electronics Co., Ltd.
9 // The user of this software agrees not to disclose, disseminate or copy such
10 // Confidential Information and shall use the software only in accordance with
11 // the terms of the license agreement the user entered into with Samsung.
12 //
13
14 #include "ControlManager.h"
15 #include <FApp.h>
16 #include <FUi.h>
17 #include <FIo.h>
18 #include "TouchForm.h"
19
20 using namespace Tizen::App;
21 using namespace Tizen::Base;
22
23 static const String TEMP_VCARD_PATH = L"/opt/temp.vcf";
24
25 ControlManager::ControlManager()
26     : __provider("")
27     , __operation("")
28 {
29     __data.Construct();
30 }
31
32 ControlManager::~ControlManager()
33 {
34 }
35
36 ControlManager*
37 ControlManager::GetInstance()
38 {
39     static ControlManager __manager;
40     return &__manager;
41 }
42
43
44 void
45 ControlManager::StartControl(void)
46 {
47     AppControl* pAc = AppManager::FindAppControlN(__provider, __operation);
48     if (pAc)
49     {
50         pAc->Start(null, null, &__data, null);
51         delete pAc;
52     }
53     __data.RemoveAll();
54 }
55
56 void
57 ControlManager::ShowText(Tizen::Base::String __text)
58 {
59     __provider   = L"";
60     __operation  = L"";
61     Tizen::Ui::Controls::MessageBox msgBox;
62     msgBox.Construct("Text Recognized", __text, Tizen::Ui::Controls::MSGBOX_STYLE_OK);
63     int modalResult;
64     msgBox.ShowAndWait(modalResult);
65 }
66
67 void
68 ControlManager::ShowUrl(Tizen::Base::String __url)
69 {
70
71     __provider   = L"tizen.internet";
72     __operation  = L"http://tizen.org/appcontrol/operation/view";
73
74     String urlKey("url");
75     String urlVal(__url);
76     __data.Add(&urlKey, &urlVal);
77
78     StartControl();
79 }
80
81 void
82 ControlManager::ShowSms(Tizen::Base::String __numbers, Tizen::Base::String __body)
83 {
84     __provider   = L"tizen.messages";
85     __operation  = L"http://tizen.org/appcontrol/operation/compose";
86
87     String typeKey = L"type";
88     String typeVal = L"SMS";
89     String textKey = L"text";
90     String textVal = __body;
91     String toKey = L"to";
92     String toVal = __numbers;
93     __data.Add(&typeKey, &typeVal);
94     __data.Add(&textKey, &textVal);
95     __data.Add(&toKey, &toVal);
96     StartControl();
97 }
98
99 void
100 ControlManager::ShowContact(Tizen::Base::String __Text)
101 {
102     __provider   = L"tizen.contacts";
103     __operation  = L"http://tizen.org/appcontrol/operation/view";
104
105     String typeKey("viewType");
106     String typeVal("vcf");
107     String pathKey("path");
108     String pathVal(TEMP_VCARD_PATH);
109     __data.Add(&typeKey, &typeVal);
110     __data.Add(&pathKey, &pathVal);
111
112     Tizen::Io::File file;
113     result r = file.Construct(TEMP_VCARD_PATH, L"w+");
114     if (IsFailed(r))
115     {
116         return;
117     }
118
119     r = file.Write(__Text);
120     if (IsFailed(r))
121     {
122         return;
123     }
124
125     r = file.Flush();
126     StartControl();
127 }
128
129 void
130 ControlManager::ShowCall(Tizen::Base::String __phone)
131 {
132     __provider   = L"tizen.phone";
133     __operation  = L"http://tizen.org/appcontrol/operation/call";
134
135     String telKey(L"tel");
136     String telVal(__phone);
137     String typeKey("type");
138     String typeVal("voice");
139     __data.Add(&telKey, &telVal);
140     __data.Add(&typeKey, &typeVal);
141
142     StartControl();
143 }
144
145 void
146 ControlManager::ShowEmail(Tizen::Base::String __addr)
147 {
148     __provider   = L"tizen.email";
149     __operation  = L"http://tizen.org/appcontrol/operation/compose";
150
151     StartControl();
152 }