Initialize the project.
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 20 Dec 2012 08:14:23 +0000 (17:14 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 20 Dec 2012 08:14:23 +0000 (17:14 +0900)
Change-Id: Ib593fbf67f88df99ef4c849b1f472e69b0472ccb

15 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
include/CModule.h [new file with mode: 0644]
include/c-abi.h [new file with mode: 0644]
include/debug.h [new file with mode: 0644]
include/dlist.h [new file with mode: 0644]
include/livebox-cpp.h [new file with mode: 0644]
include/livebox-cpp_PG.h [new file with mode: 0644]
include/livebox-impl.h [new file with mode: 0644]
liblivebox-cpp.manifest [new file with mode: 0644]
livebox-cpp.pc.in [new file with mode: 0644]
packaging/liblivebox-cpp.spec [new file with mode: 0644]
src/CModule.cpp [new file with mode: 0644]
src/dlist.cpp [new file with mode: 0644]
src/livebox.cpp [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6ea18c0
--- /dev/null
@@ -0,0 +1,55 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(livebox-cpp CXX)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR "\${exec_prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.0.1")
+
+set(CMAKE_SKIP_BUILD_RPATH true)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       dlog
+       livebox
+       livebox-service
+)
+
+FOREACH(flag ${pkgs_CXXFLAGS})
+       SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -fvisibility=hidden -fPIC -g")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -g")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"")
+ADD_DEFINITIONS("-DNDEBUG")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED
+       src/dlist.cpp
+       src/livebox.cpp
+       src/CModule.cpp
+)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl")
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/livebox-cpp.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/livebox-cpp_PG.h DESTINATION /usr/share/doc/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}")
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..27daa90
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,83 @@
+Flora License 
+
+Version 1.0, May, 2012 
+
+http://www.tizenopensource.org/license 
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 
+
+1. Definitions. 
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 
+
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent. 
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 
+
+You must give any other recipients of the Work or Derivative Works a copy of this License; and 
+You must cause any modified files to carry prominent notices stating that You changed the files; and 
+You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 
+If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 
+
+END OF TERMS AND CONDITIONS 
+
+APPENDIX: How to apply the Flora License to your work 
+
+To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 
+
+   Copyright [yyyy] [name of copyright owner] 
+
+
+   Licensed under the Flora License, Version 1.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.tizenopensource.org/license 
+
+
+   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. 
diff --git a/include/CModule.h b/include/CModule.h
new file mode 100644 (file)
index 0000000..baed1f6
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+class CModule
+{
+private:
+       static const char *m_sModulePath;
+       static struct dlist *m_pModuleList;
+
+       void *m_pHandle;
+       void *(*m_fNew)(void);
+       char *m_sPkgname;
+       struct dlist *m_pList;
+       int (*m_fNeedToCreate)(const char *cluster, const char *category);
+       int (*m_fInitialize)(const char *pkgname);
+       int (*m_fFinalize)(void);
+
+       CModule(char *pkgname) : m_pHandle(NULL), m_fNew(NULL), m_sPkgname(pkgname), m_pList(NULL), m_fNeedToCreate(NULL), m_fInitialize(NULL), m_fFinalize(NULL) {}
+       virtual ~CModule() {}
+
+public:
+       static CModule *FindModule(const char *pkgname);
+
+       static CModule *Load(const char *pkgname);
+       int Unload(void);
+
+       int Create(const char *filename, const char *content, const char *cluster, const char *category);
+       int NeedToCreate(const char *cluster, const char *category);
+       int Destroy(CLiveBoxImpl *inst);
+
+       CLiveBoxImpl *FindLiveBox(const char *filename);
+
+       const char *PackageName(void) { return m_sPkgname; }
+};
+
+/* End of a file */
diff --git a/include/c-abi.h b/include/c-abi.h
new file mode 100644 (file)
index 0000000..a8ae6af
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int livebox_initialize(const char *pkgname);
+extern int livebox_finalize(const char *pkgname);
+
+extern int livebox_create(const char *pkgname, const char *filename, const char *content, const char *cluster, const char *category);
+extern int livebox_destroy(const char *pkgname, const char *filename);
+extern int livebox_need_to_update(const char *pkgname, const char *filename);
+extern int livebox_need_to_destroy(const char *pkgname, const char *filename);
+extern int livebox_update_content(const char *pkgname, const char *filename);
+
+/*!
+ * \param[in] event "clicked" only
+ */
+extern int livebox_clicked(const char *pkgname, const char *filename, const char *event, double timestamp, double x, double y);
+
+/*!
+ * if "source" == "filename", emission could be "pd,show", "pd,hide", "lb,show", "lb,hide".
+ */
+extern int livebox_content_event(const char *pkgname, const char *filename, const char *emission, const char *source, struct event_info *event_info);
+extern int livebox_resize(const char *pkgname, const char *filename, int type);
+extern int livebox_change_group(const char *pkgname, const char *filename, const char *cluster, const char *category);
+extern int livebox_get_info(const char *pkgname, const char *filename, int *w, int *h, double *priority, char **content, char **title);
+extern int livebox_need_to_create(const char *pkgname, const char *cluster, const char *category);
+extern char *livebox_pinup(const char *pkgname, const char *filename, int pinup);
+extern int livebox_is_pinned_up(const char *pkgname, const char *filename);
+extern int livebox_system_event(const char *pkgname, const char *filename, int event);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of a file */
diff --git a/include/debug.h b/include/debug.h
new file mode 100644 (file)
index 0000000..925dd47
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+#define DbgPrint(format, arg...)       LOGD("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrint(format, arg...)       LOGE("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+/* End of a file */
diff --git a/include/dlist.h b/include/dlist.h
new file mode 100644 (file)
index 0000000..a0ad1a0
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+#define dlist_remove_data(list, data) do { \
+       struct dlist *l; \
+       l = dlist_find_data(list, data); \
+       list = dlist_remove(list, l); \
+} while (0)
+
+#define dlist_foreach(list, l, data) \
+       for ((l) = (list); ((data) = dlist_data(l)); (l) = dlist_next(l))
+
+#define dlist_foreach_safe(list, l, n, data) \
+       for ((l) = (list), (n) = dlist_next(l); \
+               ((data) = dlist_data(l)); \
+               (l) = (n), (n) = dlist_next(l))
+
+struct dlist;
+
+extern struct dlist *dlist_append(struct dlist *list, void *data);
+extern struct dlist *dlist_prepend(struct dlist *list, void *data);
+extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l);
+extern struct dlist *dlist_find_data(struct dlist *list, void *data);
+extern void *dlist_data(struct dlist *l);
+extern struct dlist *dlist_next(struct dlist *l);
+extern struct dlist *dlist_prev(struct dlist *l);
+extern int dlist_count(struct dlist *l);
+extern struct dlist *dlist_nth(struct dlist *l, int nth);
+
+/* End of a file */
diff --git a/include/livebox-cpp.h b/include/livebox-cpp.h
new file mode 100644 (file)
index 0000000..ba864b9
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/* Pure virtual class */
+class CLiveBox
+{
+public:
+       CLiveBox(void) {};
+       virtual ~CLiveBox(void) {}
+
+       virtual int Create(const char *filename, const char *content, const char *cluster, const char *category) = 0;
+       virtual int Destroy(void) = 0;
+
+       virtual int NeedToUpdate(void) = 0;
+       virtual int NeedToDestroy(void) = 0;
+       virtual int UpdateContent(void) = 0;
+
+       /*!
+        * \param[in] event "clicked" only
+        */
+       virtual int Clicked(const char *event, double timestamp, double x, double  y) = 0;
+       virtual int ContentEvent(const char *emission, const char *source, struct event_info *info) = 0;
+
+       /*!
+        * if "source" == "filename", emission could be "pd,show", "pd,hide", "lb,show", "lb,hide".
+        */
+       virtual int Resize(int type) = 0;
+       virtual int ChangeGroup(const char *cluster, const char *category) = 0;
+       virtual int GetInfo(int *w, int *h, double *priority, char **content, char **title) = 0;
+       virtual char *PinUp(int on_pin) = 0;
+       virtual const char *Filename(void) = 0;
+       virtual int IsPinnedUp(void) = 0;
+       virtual int SystemEvent(int event) = 0;
+};
+
+/* End of a file */
diff --git a/include/livebox-cpp_PG.h b/include/livebox-cpp_PG.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/include/livebox-impl.h b/include/livebox-impl.h
new file mode 100644 (file)
index 0000000..ddedc2a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+class CLiveBoxImpl : public CLiveBox
+{
+public:
+       CLiveBoxImpl(void);
+       virtual ~CLiveBoxImpl(void);
+
+       int Create(const char *filename, const char *content, const char *cluster, const char *category);
+       int Destroy(void);
+
+       int NeedToCreate(void);
+       int UpdateContent(void);
+
+       int Clicked(const char *event, double timestamp, double x, double y);
+       int ContentEvent(const char *emission, const char *source, struct event_info *info);
+
+       int Resize(int type);
+       int ChangeGroup(const char *cluster, const char *category);
+       int GetInfo(int *w, int *h, double *priority, char **content, char **title);
+       char *PinUp(int on_pin);
+       const char *Filename(void);
+       int IsPinnedUp(void);
+       int SystemEvent(int event);
+};
+
+// End of a file
diff --git a/liblivebox-cpp.manifest b/liblivebox-cpp.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/livebox-cpp.pc.in b/livebox-cpp.pc.in
new file mode 100644 (file)
index 0000000..66e1c50
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: livebox-cpp
+Description: livebox CPP supporting library
+Version: @VERSION@
+Libs: -L${libdir} -llivebox-cpp
+Cflags: -I${includedir}
+cppflags: -I${includedir}
diff --git a/packaging/liblivebox-cpp.spec b/packaging/liblivebox-cpp.spec
new file mode 100644 (file)
index 0000000..12a0873
--- /dev/null
@@ -0,0 +1,48 @@
+Name: liblivebox-cpp
+Summary: C++ adaptor for a livebox 
+Version: 0.2.2
+Release: 1
+Group: main/app
+License: Flora License
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake, gettext-tools
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(livebox)
+BuildRequires: pkgconfig(livebox-service)
+
+%description
+Livebox development library (C++)
+
+%package devel
+Summary: Files for livebox development.
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Livebox development library (C++) (dev)
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+
+%post
+
+%files -n liblivebox-cpp
+%manifest liblivebox-cpp.manifest
+%defattr(-,root,root,-)
+/usr/lib/*.so*
+/usr/share/license/*
+
+%files devel
+%defattr(-,root,root,-)
+/usr/include/livebox-cpp/livebox-cpp.h
+/usr/share/doc/livebox-cpp/livebox-cpp_PG.h
+/usr/lib/pkgconfig/*.pc
diff --git a/src/CModule.cpp b/src/CModule.cpp
new file mode 100644 (file)
index 0000000..511a74f
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <dlfcn.h>
+
+#include <dlog.h>
+#include <livebox-service.h>
+
+#include "debug.h"
+#include "livebox-cpp.h"
+#include "livebox-impl.h"
+#include "CModule.h"
+#include "dlist.h"
+
+const char *CModule::m_sModulePath = "/opt/usr/live/%s/libexec/liblive-%s.so";
+struct dlist *CModule::m_pModuleList = NULL;
+
+CModule *CModule::Load(const char *pkgname)
+{
+       CModule *inst;
+       char *tmp;
+       char *module_path;
+       int ret;
+
+       tmp = strdup(pkgname);
+       if (!tmp) {
+               ErrPrint("Memory: %s\n", strerror(errno));
+               return NULL;
+       }
+
+       try {
+               inst = new CModule(tmp);
+       } catch (...) {
+               ErrPrint("Memory\n");
+               free(tmp);
+               return NULL;
+       }
+
+       module_path = livebox_service_libexec(pkgname);
+       if (!module_path) {
+               delete inst;
+               free(tmp);
+               return NULL;
+       }
+
+       inst->m_pHandle = dlopen(module_path, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND);
+       free(module_path);
+
+       if (!inst->m_pHandle) {
+               ErrPrint("dlopen: %s\n", dlerror());
+               delete inst;
+               free(tmp);
+               return NULL;
+       }
+
+       inst->m_fNew = (void *(*)(void))dlsym(inst->m_pHandle, "livebox_new");
+       if (!inst->m_fNew) {
+               ErrPrint("symbol: livebox_new is not found: %s\n", dlerror());
+               dlclose(inst->m_pHandle);
+               delete inst;
+               free(tmp);
+               return NULL;
+       }
+
+       inst->m_fNeedToCreate = (int (*)(const char *, const char *))dlsym(inst->m_pHandle, "livebox_need_to_create");
+       if (!inst->m_fNeedToCreate)
+               DbgPrint("%s has no livebox_need_to_create\n", pkgname);
+
+       inst->m_fInitialize = (int (*)(const char *))dlsym(inst->m_pHandle, "livebox_initialize");
+       if (!inst->m_fInitialize) {
+               DbgPrint("%s has no livebox_initialize\n", pkgname);
+       } else {
+               ret = inst->m_fInitialize(pkgname);
+               if (ret < 0) {
+                       ErrPrint("livebox_finalize(%s) returns %d\n", pkgname, ret);
+                       dlclose(inst->m_pHandle);
+                       delete inst;
+                       free(tmp);
+                       return NULL;
+               }
+       }
+
+       inst->m_fFinalize = (int (*)(void))dlsym(inst->m_pHandle, "livebox_finalize");
+       if (!inst->m_fFinalize)
+               DbgPrint("%s has no livebox_finalize\n", pkgname);
+
+       m_pModuleList = dlist_append(m_pModuleList, inst);
+       return inst;
+}
+
+int CModule::Unload(void)
+{
+       struct dlist *l;
+
+       l = dlist_find_data(m_pModuleList, this);
+       m_pModuleList = dlist_remove(m_pModuleList, l);
+
+       if (m_fFinalize) {
+               int ret;
+               ret = m_fFinalize();
+               DbgPrint("livebox_finalize of %s returns %d\n", m_sPkgname, ret);
+       }
+
+       dlclose(m_pHandle);
+       free(m_sPkgname);
+       delete this;
+       return 0;
+}
+
+int CModule::Create(const char *filename, const char *content, const char *cluster, const char *category)
+{
+       CLiveBoxImpl *inst;
+
+       inst = (CLiveBoxImpl *)m_fNew();
+       if (inst) {
+               int ret;
+               ret = inst->Create(filename, content, cluster, category);
+               if (ret < 0) {
+                       delete inst;
+                       return ret;
+               }
+
+               m_pList = dlist_append(m_pList, inst);
+               return 0;
+       }
+
+       return -EFAULT;
+}
+
+int CModule::Destroy(CLiveBoxImpl *inst)
+{
+       struct dlist *l;
+
+       l = dlist_find_data(m_pList, inst);
+       if (!l)
+               return -ENOENT;
+
+       m_pList = dlist_remove(m_pList, l);
+       delete inst;
+       return 0;
+}
+
+CLiveBoxImpl *CModule::FindLiveBox(const char *filename)
+{
+       struct dlist *l;
+       void *item;
+       CLiveBoxImpl *box;
+
+       dlist_foreach(m_pList, l, item) {
+               box = (CLiveBoxImpl *)item;
+               if (!strcmp(filename, box->Filename()))
+                       return box;
+       }
+
+       return NULL;
+}
+
+int CModule::NeedToCreate(const char *cluster, const char *category)
+{
+       if (!m_fNeedToCreate)
+               return 0;
+
+       return m_fNeedToCreate(cluster, category);
+}
+
+CModule *CModule::FindModule(const char *pkgname)
+{
+       struct dlist *l;
+       void *item;
+       CModule *module;
+
+       dlist_foreach(m_pModuleList, l, item) {
+               module = (CModule *)item;
+               if (!strcmp(pkgname, module->PackageName())) {
+                       return module;
+               }
+       }
+
+       return NULL;
+}
+
+/* End of a file */
diff --git a/src/dlist.cpp b/src/dlist.cpp
new file mode 100644 (file)
index 0000000..f535d74
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "dlist.h"
+
+struct dlist {
+       struct dlist *next;
+       struct dlist *prev;
+       void *data;
+};
+
+struct dlist *dlist_append(struct dlist *list, void *data)
+{
+       struct dlist *item;
+
+       item = (struct dlist *)malloc(sizeof(*item));
+       if (!item)
+               return NULL;
+
+       item->next = NULL;
+       item->data = data;
+
+       if (!list) {
+               item->prev = item;
+
+               list = item;
+       } else {
+               item->prev = list->prev;
+               item->prev->next = item;
+
+               list->prev = item;
+       }
+
+       assert(!list->prev->next && "item NEXT");
+
+       return list;
+}
+
+struct dlist *dlist_prepend(struct dlist *list, void *data)
+{
+       struct dlist *item;
+
+       item = (struct dlist *)malloc(sizeof(*item));
+       if (!item)
+               return NULL;
+
+       if (!list) {
+               item->prev = item;
+               item->next = NULL;
+       } else {
+               item->prev = list->prev;
+               list->prev = item;
+               item->next = list;
+       }
+
+       return item;
+}
+
+struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
+{
+       if (!list || !l)
+               return NULL;
+
+       if (l == list) {
+               l->prev = list->prev;
+               list = l->next;
+       } else {
+               l->prev->next = l->next;
+       }
+
+       if (l->next)
+               l->next->prev = l->prev;
+
+       free(l);
+       return list;
+}
+
+struct dlist *dlist_find_data(struct dlist *list, void *data)
+{
+       struct dlist *l;
+       void *_data;
+
+       dlist_foreach(list, l, _data) {
+               if (data == _data)
+                       return l;
+       }
+
+       return NULL;
+}
+
+void *dlist_data(struct dlist *l)
+{
+       return l ? l->data : NULL;
+}
+
+struct dlist *dlist_next(struct dlist *l)
+{
+       return l ? l->next : NULL;
+}
+
+struct dlist *dlist_prev(struct dlist *l)
+{
+       return l ? l->prev : NULL;
+}
+
+int dlist_count(struct dlist *l)
+{
+       register int i;
+       struct dlist *n;
+       void *data;
+
+       i = 0;
+       dlist_foreach(l, n, data) {
+               i++;
+       }
+
+       return i;
+}
+
+struct dlist *dlist_nth(struct dlist *l, int nth)
+{
+       register int i;
+       struct dlist *n;
+       void *data;
+
+       i = 0;
+       dlist_foreach(l, n, data) {
+               if (i == nth)
+                       return l;
+
+               i++;
+       }
+
+       return NULL;
+}
+
+/* End of a file */
diff --git a/src/livebox.cpp b/src/livebox.cpp
new file mode 100644 (file)
index 0000000..d68d030
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <stdio.h>
+#include <errno.h>
+
+#include <dlog.h>
+#include <livebox.h>
+
+#include "livebox-cpp.h"
+#include "livebox-impl.h"
+#include "CModule.h"
+#include "c-abi.h"
+
+#define EAPI __attribute__((visibility("default")))
+
+EAPI int livebox_initialize(const char *pkgname)
+{
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (module)
+               return 0;
+
+       module = CModule::Load(pkgname);
+       if (!module)
+               return -EFAULT;
+
+       return 0;
+}
+
+EAPI int livebox_finalize(const char *pkgname)
+{
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -ENOENT;
+
+       module->Unload();
+       return 0;
+}
+
+EAPI int livebox_create(const char *pkgname, const char *filename, const char *content, const char *cluster, const char *category)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+       int ret;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (box)
+               return -EEXIST;
+
+       ret = module->Create(filename, content, cluster, category);
+       return ret;
+}
+
+EAPI int livebox_destroy(const char *pkgname, const char *filename)
+{
+       CModule *module;
+       CLiveBoxImpl *box;
+       int ret;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       ret = module->Destroy(box);
+       return ret;
+}
+
+EAPI int livebox_need_to_update(const char *pkgname, const char *filename)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       return box->NeedToUpdate();
+}
+
+EAPI int livebox_need_to_destroy(const char *pkgname, const char *filename)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+       
+       return box->NeedToDestroy();
+}
+
+EAPI int livebox_update_content(const char *pkgname, const char *filename)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+       
+       return box->UpdateContent();
+}
+
+EAPI int livebox_clicked(const char *pkgname, const char *filename, const char *event, double timestamp, double x, double y)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       return box->Clicked(event, timestamp, x, y);
+}
+
+EAPI int livebox_content_event(const char *pkgname, const char *filename, const char *emission, const char *source, struct event_info *event_info)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       return box->ContentEvent(emission, source, event_info);
+}
+
+EAPI int livebox_resize(const char *pkgname, const char *filename, int type)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       return box->Resize(type);
+}
+
+EAPI int livebox_change_group(const char *pkgname, const char *filename, const char *cluster, const char *category)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       return box->ChangeGroup(cluster, category);
+}
+
+EAPI int livebox_get_info(const char *pkgname, const char *filename, int *w, int *h, double *priority, char **content, char **title)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return -ENOENT;
+
+       return box->GetInfo(w, h, priority, content, title);
+}
+
+EAPI int livebox_need_to_create(const char *pkgname, const char *cluster, const char *category)
+{
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return -EINVAL;
+
+       return module->NeedToCreate(cluster, category);
+}
+
+EAPI char *livebox_pinup(const char *pkgname, const char *filename, int pinup)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return NULL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return NULL;
+
+       return box->PinUp(pinup);
+}
+
+EAPI int livebox_is_pinned_up(const char *pkgname, const char *filename)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return NULL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return NULL;
+
+       return box->IsPinnedUp();
+}
+
+EAPI int livebox_system_event(const char *pkgname, const char *filename, int event)
+{
+       CLiveBoxImpl *box;
+       CModule *module;
+
+       module = CModule::FindModule(pkgname);
+       if (!module)
+               return NULL;
+
+       box = module->FindLiveBox(filename);
+       if (!box)
+               return NULL;
+
+       return box->SystemEvent(event);
+}
+
+/* End of a file */