[TV][Channel] Implementation of getCurrentChannel
authorLukasz Foniok <l.foniok@samsung.com>
Tue, 16 Dec 2014 10:41:08 +0000 (11:41 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 2 Feb 2015 11:05:26 +0000 (20:05 +0900)
[Verification]
tizen.tvchannel.getCurrentChannel("MAIN") should work.

Change-Id: Ifc01026782084381c4018782a84a6439e08ba461
Signed-off-by: Lukasz Foniok <l.foniok@samsung.com>
src/tvchannel/channel_info.cc [new file with mode: 0644]
src/tvchannel/channel_info.h [new file with mode: 0644]
src/tvchannel/tvchannel.gyp
src/tvchannel/tvchannel_extension.cc
src/tvchannel/tvchannel_extension.h
src/tvchannel/tvchannel_instance.cc
src/tvchannel/tvchannel_instance.h
src/tvchannel/tvchannel_manager.cc
src/tvchannel/tvchannel_manager.h
src/tvchannel/types.cc [new file with mode: 0644]
src/tvchannel/types.h [new file with mode: 0644]

diff --git a/src/tvchannel/channel_info.cc b/src/tvchannel/channel_info.cc
new file mode 100644 (file)
index 0000000..04ab032
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tvchannel/channel_info.h"
+#include <stdint.h>
+#include <string>
+#include "tvchannel/tvchannel_manager.h"
+#include "common/logger.h"
+
+namespace extension {
+namespace tvchannel {
+
+ChannelInfo::ChannelInfo() :
+    m_major(0), m_minor(0), m_channelName(""), m_programNumber(0), m_ptc(0),
+        m_lcn(0), m_sourceID(0), m_transportStreamID(0), m_originalNetworkID(0),
+        m_serviceName(""), m_serviceID(0) {
+}
+
+ChannelInfo::~ChannelInfo() {
+}
+
+void ChannelInfo::fromApiData(const TCServiceData &channelData) {
+    LOGD("Enter");
+    m_ptc = channelData.Get<u_int16_t>(CHANNEL_NUMBER);
+    m_major = channelData.Get<u_int16_t>(MAJOR);
+    m_minor = channelData.Get<u_int16_t>(MINOR);
+    m_lcn = channelData.Get<u_int16_t>(LCN);
+    m_sourceID = channelData.Get<u_int16_t>(SOURCE_ID);
+    m_programNumber = channelData.Get<u_int16_t>(PROGRAM_NUMBER);
+    m_transportStreamID = channelData.Get<u_int16_t>(TRANSPORT_STREAM_ID);
+    m_originalNetworkID = channelData.Get<u_int16_t>(ORIGINAL_NETWORK_ID);
+    m_serviceID = channelData.Get < TCServiceId > (SERVICE_ID);
+
+    setChannelName(channelData);
+    setServiceName(channelData);
+}
+
+int64_t ChannelInfo::getMajor() const {
+    return m_major;
+}
+
+void ChannelInfo::setMajor(int64_t major) {
+    m_major = major;
+}
+
+int64_t ChannelInfo::getMinor() const {
+    return m_minor;
+}
+
+void ChannelInfo::setMinor(int64_t minor) {
+    m_minor = minor;
+}
+
+std::string ChannelInfo::getChannelName() const {
+    return m_channelName;
+}
+
+void ChannelInfo::setChannelName(std::string channelName) {
+    m_channelName = channelName;
+}
+
+void ChannelInfo::setChannelName(const TCServiceData &channelData) {
+    LOGD("Enter");
+    size_t len = channelData.GetLength(SERVICE_NAME);
+    if (len) {
+        LOGD("ServiceName length %d", len);
+        size_t c_len = len * sizeof(t_wchar_t) / sizeof(char);
+        t_wchar_t svc_name[len + 1];
+        channelData.Get(SERVICE_NAME, svc_name);
+        char name[CHANNEL_NAME_MAX_SIZE];
+        TVChannelManager::ucs2utf8(name, sizeof(name),
+            reinterpret_cast<char *>(svc_name), c_len);
+        m_channelName = name;
+    } else {
+        m_channelName = "";
+    }
+}
+
+int64_t ChannelInfo::getProgramNumber() const {
+    return m_programNumber;
+}
+
+void ChannelInfo::setProgramNumber(int64_t programNumber) {
+    m_programNumber = programNumber;
+}
+
+int64_t ChannelInfo::getPtc() const {
+    return m_ptc;
+}
+
+void ChannelInfo::setPtc(int64_t ptc) {
+    m_ptc = ptc;
+}
+
+int64_t ChannelInfo::getLcn() const {
+    return m_lcn;
+}
+
+void ChannelInfo::setLcn(int64_t lcn) {
+    m_lcn = lcn;
+}
+
+int64_t ChannelInfo::getSourceID() const {
+    return m_sourceID;
+}
+
+void ChannelInfo::setSourceID(int64_t sourceID) {
+    m_sourceID = sourceID;
+}
+
+int64_t ChannelInfo::getTransportStreamID() const {
+    return m_transportStreamID;
+}
+
+void ChannelInfo::setTransportStreamID(int64_t transportStreamID) {
+    m_transportStreamID = transportStreamID;
+}
+
+int64_t ChannelInfo::getOriginalNetworkID() const {
+    return m_originalNetworkID;
+}
+
+void ChannelInfo::setOriginalNetworkID(int64_t originalNetworkID) {
+    m_originalNetworkID = originalNetworkID;
+}
+
+std::string ChannelInfo::getServiceName() const {
+    return getChannelName();
+}
+
+void ChannelInfo::setServiceName(std::string serviceName) {
+    setChannelName(serviceName);
+}
+
+void ChannelInfo::setServiceName(const TCServiceData &data) {
+    setChannelName(data);
+}
+
+TCServiceId ChannelInfo::getServiceID() const {
+    return m_serviceID;
+}
+
+void ChannelInfo::setServiceID(TCServiceId serviceID) {
+    m_serviceID = serviceID;
+}
+
+}  //  namespace tvchannel
+}  //  namespace extension
diff --git a/src/tvchannel/channel_info.h b/src/tvchannel/channel_info.h
new file mode 100644 (file)
index 0000000..736522d
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SRC_TVCHANNEL_CHANNEL_INFO_H_
+#define SRC_TVCHANNEL_CHANNEL_INFO_H_
+
+#include <ServiceData.h>
+#include <string>
+#include "tvchannel/types.h"
+
+namespace extension {
+namespace tvchannel {
+
+class ChannelInfo {
+ public:
+    ChannelInfo();
+    virtual ~ChannelInfo();
+
+    void fromApiData(const TCServiceData &channelData);
+
+    int64_t getMajor() const;
+    void setMajor(int64_t major);
+
+    int64_t getMinor() const;
+    void setMinor(int64_t minor);
+
+    std::string getChannelName() const;
+    void setChannelName(std::string channelName);
+    void setChannelName(const TCServiceData &channelData);
+
+    int64_t getProgramNumber() const;
+    void setProgramNumber(int64_t programNumber);
+
+    int64_t getPtc() const;
+    void setPtc(int64_t ptc);
+
+    int64_t getLcn() const;
+    void setLcn(int64_t lcn);
+
+    int64_t getSourceID() const;
+    void setSourceID(int64_t sourceID);
+
+    int64_t getTransportStreamID() const;
+    void setTransportStreamID(int64_t transportStreamID);
+
+    int64_t getOriginalNetworkID() const;
+    void setOriginalNetworkID(int64_t originalNetworkID);
+
+    std::string getServiceName() const;
+    void setServiceName(std::string serviceName);
+    void setServiceName(const TCServiceData &channelData);
+
+    TCServiceId getServiceID() const;
+    void setServiceID(TCServiceId serviceID);
+
+ private:
+    int64_t m_major;
+    int64_t m_minor;
+    std::string m_channelName;
+    int64_t m_programNumber;
+    int64_t m_ptc;
+    int64_t m_lcn;
+    int64_t m_sourceID;
+    int64_t m_transportStreamID;
+    int64_t m_originalNetworkID;
+    std::string m_serviceName;
+    TCServiceId m_serviceID;
+
+    static const int CHANNEL_NAME_MAX_SIZE = 128;
+};
+
+}  //  namespace tvchannel
+}  //  namespace extension
+
+#endif  // SRC_TVCHANNEL_CHANNEL_INFO_H_
index 00d981e2206863231ca6ecc978879a0357c370f5..1c72f1da0b99f4a16e665e9d8b123f01ec1f13cc 100644 (file)
       'includes': [
         '../common/pkg-config.gypi',
       ],
+      'conditions': [
+       ['tizen == 1', {
+        'variables': {
+            'packages': [
+             'tvs-api'
+            ],
+        },
+       },
+      ],
+      ],
       'sources': [
         'tvchannel_api.js',
         'tvchannel_error.h',
         'tvchannel_extension.h',
         'tvchannel_instance.cc',
         'tvchannel_instance.h',
+        'channel_info.cc',
+        'channel_info.h',
+        'tvchannel_manager.h',
+        'tvchannel_manager.cc',
+        'types.h',
+        'types.cc'
       ],
     },
   ],
index 445fbfc3469fa11d8d4c9c9b8f1b18d5412698cf..393f7e71ecaa3988c09bce175904f8b21348992f 100644 (file)
@@ -8,27 +8,20 @@
 // This will be generated from datasync_api.js.
 extern const char kSource_tvchannel_api[];
 
-namespace tvchannel {
-
 TVChannelExtension::TVChannelExtension() {
-  SetExtensionName("tizen.tvchannel");
-  SetJavaScriptAPI(kSource_tvchannel_api);
+    SetExtensionName("tizen.tvchannel");
+    SetJavaScriptAPI(kSource_tvchannel_api);
 }
 
-TVChannelExtension::~TVChannelExtension() {}
-
-TVChannelManager& TVChannelExtension::manager() {
-  // Initialize API on first request
-  return TVChannelManager::getInstance();
+TVChannelExtension::~TVChannelExtension() {
 }
 
 common::Instance* TVChannelExtension::CreateInstance() {
-  return new TVChannelInstance(*this);
+    return new extension::tvchannel::TVChannelInstance();
 }
 
-}  // namespace tvchannel
-
 // entry point
 common::Extension* CreateExtension() {
-  return new tvchannel::TVChannelExtension;
+    return new TVChannelExtension();
 }
+
index 15b3969f6370245402807006e280604ed960dd8c..1d4f8356d6a7c31c65f7d852b221e9d8f89a0796 100644 (file)
@@ -6,22 +6,13 @@
 #define SRC_TVCHANNEL_TVCHANNEL_EXTENSION_H_
 
 #include "common/extension.h"
-#include "tvchannel/tvchannel_manager.h"
 
-namespace tvchannel {
-
-class TVChannelExtension : public common::Extension {
+class TVChannelExtension: public common::Extension {
  public:
     TVChannelExtension();
     virtual ~TVChannelExtension();
-
-    TVChannelManager& manager();
-
  private:
-    // common::Extension implementation.
     virtual common::Instance* CreateInstance();
 };
 
-}  // namespace tvchannel
-
 #endif  // SRC_TVCHANNEL_TVCHANNEL_EXTENSION_H_
index 16db23624c133376704b99c95d76813039b662c0..9ceb589ad5093e18f9c850e53077b6c104de3656 100644 (file)
@@ -3,31 +3,73 @@
 // found in the LICENSE file.
 
 #include "tvchannel/tvchannel_instance.h"
+#include <functional>
+#include <memory>
 #include "common/logger.h"
 #include "tizen/tizen.h"
 #include "common/picojson.h"
+#include "tvchannel/tvchannel_manager.h"
+#include "tvchannel/channel_info.h"
 
+namespace extension {
 namespace tvchannel {
 
-TVChannelInstance::TVChannelInstance(TVChannelExtension const& extension) {
-    LoggerE("Entered");
+TVChannelInstance::TVChannelInstance() {
+    LOGE("Entered");
+    RegisterSyncHandler("TVChannelManager_getCurrentChannel",
+        std::bind(&TVChannelInstance::getCurrentChannel, this,
+            std::placeholders::_1,
+            std::placeholders::_2));
 }
 
 TVChannelInstance::~TVChannelInstance() {
-    LoggerE("Entered");
+    LOGE("Entered");
 }
 
-void TVChannelInstance::HandleMessage(const char* msg) {
-    // this is stub, no async messages
-    LoggerE("Entered");
-}
+void TVChannelInstance::getCurrentChannel(picojson::value const& args,
+    picojson::object& out) {
+    std::unique_ptr< ChannelInfo > pChannel = TVChannelManager::getInstance()->getCurrentChannel(
+        args.get("windowType").get<std::string>());
+
+    picojson::value::object channel;
+    channel.insert(
+        std::make_pair("major",
+            picojson::value(static_cast<double>(pChannel->getMajor()))));
+    channel.insert(
+        std::make_pair("minor",
+            picojson::value(static_cast<double>(pChannel->getMinor()))));
+    channel.insert(
+        std::make_pair("channelName",
+            picojson::value(pChannel->getChannelName())));
+    channel.insert(
+        std::make_pair("programNumber",
+            picojson::value(
+                static_cast<double>(pChannel->getProgramNumber()))));
+    channel.insert(
+        std::make_pair("ptc",
+            picojson::value(static_cast<double>(pChannel->getPtc()))));
+    channel.insert(
+        std::make_pair("lcn",
+            picojson::value(static_cast<double>(pChannel->getLcn()))));
+    channel.insert(
+        std::make_pair("sourceID",
+            picojson::value(static_cast<double>(pChannel->getSourceID()))));
+    channel.insert(
+        std::make_pair("transportStreamID",
+            picojson::value(
+                static_cast<double>(pChannel->getTransportStreamID()))));
+    channel.insert(
+        std::make_pair("originalNetworkID",
+            picojson::value(
+                static_cast<double>(pChannel->getOriginalNetworkID()))));
+    channel.insert(
+        std::make_pair("serviceName",
+            picojson::value(pChannel->getServiceName())));
 
-void TVChannelInstance::HandleSyncMessage(const char* msg) {
-    LoggerE("Entered %s", msg);
-    picojson::object answer;
-    answer["answer"] = picojson::value(true);
+    picojson::value v(channel);
 
-    SendSyncReply(picojson::value(answer).serialize().c_str());
+    ReportSuccess(v, out);
 }
 
 }  // namespace tvchannel
+}  // namespace extension
index 02c83716095b573557587d564f775b70ac5cff2d..5509c069afd9d26237549531fd0e057dd4567cf1 100644 (file)
 
 #include "tvchannel/tvchannel_extension.h"
 
+namespace extension {
 namespace tvchannel {
 
-class TVChannelInstance : public common::Instance {
+class TVChannelInstance: public common::ParsedInstance {
  public:
-  explicit TVChannelInstance(TVChannelExtension const& extension);
-  virtual ~TVChannelInstance();
+    TVChannelInstance();
+    virtual ~TVChannelInstance();
 
  private:
-  virtual void HandleMessage(const char* msg);
-  virtual void HandleSyncMessage(const char* msg);
+    void getCurrentChannel(const picojson::value& args, picojson::object& out);
 };
 
 }  // namespace tvchannel
+}  // namespace extension
 
 #endif  // SRC_TVCHANNEL_TVCHANNEL_INSTANCE_H_
index b0bbe91b3a2af86510ad6f91bf6f98cad64e8ca8..274c0c31a3127e9b52e171df7c6c9ddb8e96fad9 100644 (file)
@@ -3,12 +3,97 @@
 // found in the LICENSE file.
 
 #include "tvchannel/tvchannel_manager.h"
+#include <iconv.h>
+#include "tvchannel/channel_info.h"
+#include "common/logger.h"
+#include "common/platform_exception.h"
 
+namespace extension {
 namespace tvchannel {
 
-TVChannelManager& TVChannelManager::getInstance() {
+TVChannelManager* TVChannelManager::getInstance() {
     static TVChannelManager manager;
-    return manager;
+    return &manager;
 }
 
+std::unique_ptr<ChannelInfo> TVChannelManager::getCurrentChannel(
+        std::string const& _windowType) {
+    LOGE("Entered %s", _windowType.c_str());
+
+    TCServiceData serviceData;
+    TCCriteriaHelper criteria;
+    criteria.Fetch(SERVICE_ID);
+    criteria.Fetch(MAJOR);
+    criteria.Fetch(MINOR);
+    criteria.Fetch(PROGRAM_NUMBER);
+    criteria.Fetch(CHANNEL_NUMBER);
+    criteria.Fetch(CHANNEL_TYPE);
+    criteria.Fetch(SERVICE_NAME);
+    criteria.Fetch(SOURCE_ID);
+    criteria.Fetch(TRANSPORT_STREAM_ID);
+    criteria.Fetch(ORIGINAL_NETWORK_ID);
+    criteria.Fetch(LCN);
+
+    //  Navigation
+    IServiceNavigation* navigation;
+    int ret = TVServiceAPI::CreateServiceNavigation(
+            getProfile(stringToWindowType(_windowType)), 0, &navigation);
+    if (TV_SERVICE_API_SUCCESS != ret) {
+        LoggerE("Failed to create service navigation: %d", ret);
+        throw common::UnknownException("Failed to create service navigation");
+    }
+
+    struct TSTvMode tvMode;
+    ret = navigation->GetTvMode(tvMode);
+    if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
+        LoggerE("Failed to get current tv mode: %d", ret);
+        throw common::UnknownException("Failed to get current tv mode");
+    }
+    LOGE("tvMode : antenna - %d, service - %d", tvMode.antennaMode,
+            tvMode.serviceMode);
+
+    ret = navigation->GetCurrentServiceInfo(tvMode, criteria, serviceData);
+    if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
+        LOGE("Failed to get current service info: %d", ret);
+        throw common::UnknownException("Failed to get current service info");
+    }
+    LoggerE("Current channel id: %llu",
+            serviceData.Get < TCServiceId > (SERVICE_ID));
+    std::unique_ptr<ChannelInfo> pChannel( new ChannelInfo() );
+    pChannel->fromApiData(serviceData);
+    return pChannel;
+}
+
+EProfile TVChannelManager::getProfile(WindowType windowType) {
+    LOGE("Enter");
+    switch (windowType) {
+    case MAIN:
+        return PROFILE_TYPE_MAIN;
+// PIP is not supported - j.h.lim
+//      case PIP:
+//          return PROFILE_TYPE_PIP;
+    default:
+        LOGE("Unsupported window type: %d", windowType);
+    }
 }
+
+void TVChannelManager::ucs2utf8(char *out, size_t out_len, char *in,
+        size_t in_len) {
+    iconv_t cd;
+    size_t r;
+
+    cd = iconv_open("UTF-8", "UCS-2BE");
+    if (cd == (iconv_t) - 1) {
+        LOGE("Failed to open iconv");
+    }
+
+    r = iconv(cd, &in, &in_len, &out, &out_len);
+    if (r == (size_t) - 1) {
+        LOGE("Failed convert string to utf8");
+    }
+
+    iconv_close(cd);
+}
+
+}  // namespace tvchannel
+}  // namespace extension
index e92e35a4f46b5a393b45455dd783410256d12907..bc8bf3e6c55cc5b7e0923716e794f1252d0fad88 100644 (file)
@@ -5,19 +5,41 @@
 #ifndef SRC_TVCHANNEL_TVCHANNEL_MANAGER_H_
 #define SRC_TVCHANNEL_TVCHANNEL_MANAGER_H_
 
+#include <string>
+#include <memory>
+#include <TVServiceAPI.h>
+#include "tvchannel/types.h"
+
+namespace extension {
 namespace tvchannel {
 
+class ChannelInfo;
+//  TVServiceAPI static methods returns 0 on success
+static const int TV_SERVICE_API_SUCCESS = 0;
+//  TVServiceAPI object methods return 1 on success
+static const int TV_SERVICE_API_METHOD_SUCCESS = 1;
+//  TVServiceAPI object methods return -1 on failure
+static const int TV_SERVICE_API_METHOD_FAILURE = -1;
+//  You need to check error return in function/method docs and use correct
+//  constant
+
 class TVChannelManager {
  public:
-    static TVChannelManager& getInstance();
-
+    static TVChannelManager* getInstance();
+    std::unique_ptr<ChannelInfo> getCurrentChannel(std::string const& _windowType);
+    static void ucs2utf8(char *out, size_t out_len, char *in, size_t in_len);
  private:
-    // Not copyable, assignable, movable
-    TVChannelManager(TVChannelManager const&);
-    void operator=(TVChannelManager const&);
-    TVChannelManager(TVChannelManager &&);
+    //  Not copyable, assignable, movable
+    TVChannelManager() {
+    }
+    TVChannelManager(TVChannelManager const&) = delete;
+    void operator=(TVChannelManager const&) = delete;
+    TVChannelManager(TVChannelManager &&) = delete;
+
+    EProfile getProfile(WindowType windowType);
 };
 
 }  // namespace tvchannel
+}  // namespace extension
 
 #endif  // SRC_TVCHANNEL_TVCHANNEL_MANAGER_H_
diff --git a/src/tvchannel/types.cc b/src/tvchannel/types.cc
new file mode 100644 (file)
index 0000000..2803877
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "tvchannel/types.h"
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+namespace extension {
+namespace tvchannel {
+
+const char* NAVIGATOR_MODE_ALL = "ALL";
+const char* NAVIGATOR_MODE_DIGITAL = "DIGITAL";
+const char* NAVIGATOR_MODE_ANALOG = "ANALOG";
+const char* NAVIGATOR_MODE_FAVORITE = "FAVORITE";
+
+NavigatorMode stringToNavigatorMode(const std::string &mode) {
+    if (mode == NAVIGATOR_MODE_ALL) {
+        return NavigatorMode::ALL;
+    }
+    if (mode == NAVIGATOR_MODE_DIGITAL) {
+        return NavigatorMode::DIGITAL;
+    }
+    if (mode == NAVIGATOR_MODE_ANALOG) {
+        return NavigatorMode::ANALOG;
+    }
+    if (mode == NAVIGATOR_MODE_FAVORITE) {
+        return NavigatorMode::FAVORITE;
+    }
+    LOGE("Unrecognized mode");
+    throw common::UnknownException("Unrecognized mode");
+}
+
+const char* TIZEN_TV_WINDOW_TYPE_MAIN = "MAIN";
+// PIP is not supported - j.h.lim
+// const char* TIZEN_TV_WINDOW_TYPE_PIP = "PIP";
+
+std::string windowTypeToString(WindowType type) {
+    switch (type) {
+    case MAIN:
+        return TIZEN_TV_WINDOW_TYPE_MAIN;
+        break;
+// PIP is not supported - j.h.lim
+//      case PIP:
+//          return TIZEN_TV_WINDOW_TYPE_PIP;
+//          break;
+    default:
+        LOGE("Unrecognized window type: %d", type);
+        throw common::UnknownException("Unrecognized window type");
+    }
+}
+
+WindowType stringToWindowType(std::string type) {
+    if (type == TIZEN_TV_WINDOW_TYPE_MAIN) {
+        return MAIN;
+// PIP is not supported - j.h.lim
+//  } else if (type == TIZEN_TV_WINDOW_TYPE_PIP) {
+//      return PIP;
+    } else {
+        LOGE("Unrecognized window type: %s", type.c_str());
+        throw common::UnknownException("Unrecognized window type");
+    }
+}
+
+}  //  namespace tvchannel
+}  //  namespace extension
+
diff --git a/src/tvchannel/types.h b/src/tvchannel/types.h
new file mode 100644 (file)
index 0000000..29621fe
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef SRC_TVCHANNEL_TYPES_H_
+#define SRC_TVCHANNEL_TYPES_H_
+
+#include <string>
+
+namespace extension {
+namespace tvchannel {
+
+enum NavigatorMode {
+    NOT_DEFINED,
+    ALL,
+    DIGITAL,
+    ANALOG,
+    FAVORITE
+};
+
+enum WindowType {
+    MAIN = 0,
+//  PIP is not supported - j.h.lim
+//  PIP
+};
+
+extern const char* TIZEN_TV_WINDOW_TYPE_MAIN;
+
+enum class SourceType {
+    TV,
+    AV,
+    SVIDEO,
+    COMP,
+    PC,
+    HDMI,
+    SCART,
+    DVI,
+    MEDIA,
+    IPTV,
+    UNKNOWN
+};
+
+extern const char* NAVIGATOR_MODE_ALL;
+extern const char* NAVIGATOR_MODE_DIGITAL;
+extern const char* NAVIGATOR_MODE_ANALOG;
+extern const char* NAVIGATOR_MODE_FAVORITE;
+
+NavigatorMode stringToNavigatorMode(std::string const& mode);
+std::string windowTypeToString(WindowType type);
+WindowType stringToWindowType(std::string type);
+
+}  //  namespace tvchannel
+}  //  namespace extension
+
+#endif  // SRC_TVCHANNEL_TYPES_H_