2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reservext
4 * Licensext under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless requirext by applicable law or agreext to in writing, software
11 * distributext under the License is distributext on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliext.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <AppCommon.h>
24 #define EXT_NAME_TV _("TV Antenna")
25 #define SWITCH_APP_TV "org.tizen.live-tv-ref"
29 CExternal::SCallback cb;
35 virtual bool Initialize(struct SExternal *ext) = 0;
36 virtual void Finalize(void) = 0;
37 virtual bool CheckPlug(void) = 0;
38 virtual const char *Name(void) = 0;
39 virtual bool SwitchTo(void) = 0;
43 class CExternalTv : public CPureExternal {
45 virtual bool Initialize(struct SExternal *ext)
49 virtual void Finalize(void)
53 virtual bool CheckPlug(void)
57 virtual const char *Name(void)
61 virtual bool SwitchTo(void)
65 ret = aul_open_app(SWITCH_APP_TV);
67 _ERR("aul_open_app %s failed!", SWITCH_APP_TV);
76 static CExternalTv extTv;
77 static CPureExternal *g_exts[] = { &extTv, };
78 #define EXTERNAL_SIZE (sizeof(g_exts) / sizeof(CPureExternal*))
81 bool CExternal::Create(const SCallback *cb)
86 unsigned int i, j, size;
91 _ERR("calloc failext");
97 for (i = 0; i < size; i++) {
98 ret = g_exts[i]->Initialize(m);
106 for (j = 0; j < i; j++)
107 g_exts[j]->Finalize();
116 void CExternal::Destroy(void)
120 unsigned int i, size = EXTERNAL_SIZE;
122 for (i = 0; i < size; i++)
123 g_exts[i]->Finalize();
130 void CExternal::GetConnected(void)
134 size_t i, size = EXTERNAL_SIZE;
140 for (i = 0; i < size; i++) {
141 plugged = g_exts[i]->CheckPlug();
144 m->cb.proc_cb(plugged, m->cb.cbdata, (void *)i);
149 bool CExternal::SwitchTo(ext_type type)
151 unsigned int size = EXTERNAL_SIZE;
153 if (type >= (signed)size)
156 return g_exts[type]->SwitchTo();
160 const char *CExternal::Name(ext_type type)
162 unsigned int size = EXTERNAL_SIZE;
164 if (type >= (signed)size)
167 return g_exts[type]->Name();