+++ /dev/null
-#ifndef __MANAGER_USB_H__
-#define __MANAGER_USB_H__
-
-
-class CUsbConnectionListener {
-private:
- void *m;
-
-public:
- CUsbConnectionListener() : m(NULL) {}
- virtual ~CUsbConnectionListener() {}
- bool FlagCreate(void) { return !!m; }
-
- bool Create(void);
- virtual void Destroy(void);
-
- bool FlagConnected(void);
-
- virtual void OnConnect(void) {}
-};
-
-
-#include <media_content.h>
-
-
-class CDbUpdateListener {
-public:
- struct SEntity {
- media_content_error_e err;
- int pid;
- media_content_db_update_item_type_e update_item;
- media_content_db_update_type_e update_type;
- media_content_type_e media_type;
- char *uuid;
- char *path;
- char *mime_type;
- };
-
-private:
- void *m;
-
-public:
- CDbUpdateListener() : m(NULL) {}
- virtual ~CDbUpdateListener() {}
- bool FlagCreate(void) { return !!m; }
-
- bool Create(void);
- virtual void Destroy(void);
-
- virtual void OnUpdated(const SEntity *entity) = 0;
-};
-
-
-#endif /* __MANAGER_USB_H__ */
\ No newline at end of file
+++ /dev/null
-/*
-* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <stdio.h>
-#include <stdlib.h>
-#include <Eina.h>
-#include "dbg.h"
-#include <AppCommon.h>
-#include <media_content.h>
-#include "common.h"
-#include "i18n.h"
-
-#include "ManagerUsb.h"
-
-
-class CUsbConnectionListenerImpl {
-private:
- Eina_List *m_elListener;
- bool m_created;
-
-#if 0
-private:
- static void sm_CbConnected(usb_device_h usb_device, char *action, void *dt)
- {
- CUsbConnectionListenerImpl* root = (CUsbConnectionListenerImpl*)dt;
- if (root)
- root->t_OnConnected(usb_device, action);
- }
-
-protected:
- virtual void t_OnConnected(usb_device_h usb_device, char *action) {
- Eina_List *l;
- void *obj;
-
- EINA_LIST_FOREACH(m_elListener, l, obj) {
- CUsbConnectionListener* listener = (CUsbConnectionListener*)obj;
- listener->OnConnect();
- }
- }
-#endif
-
-public:
- CUsbConnectionListenerImpl() {
- m_created = false;
- }
- ~CUsbConnectionListenerImpl() {
- }
- bool FlagCreate(void) { return !!m_created; }
-
- bool Create(void) {
- ASSERT(!FlagCreate());
- ASSERT(!"Not Yet");
-#if 0
- m_elListener = NULL;
- if (!usb_device_init()) {
- return false;
- }
- usb_set_connected_cb(sm_CbConnected, this);
-
- m_created = true;
-#endif
- return true;
- }
- virtual void Destroy(void) {
- ASSERT(FlagCreate());
-#if 0
- usb_unset_connected_cb();
- usb_device_fini();
- m_created = false;
-#endif
- }
- void Add(CUsbConnectionListener *listener) {
- ASSERT(FlagCreate());
-
- m_elListener = eina_list_append(m_elListener, listener);
- }
- void Remove(CUsbConnectionListener *listener) {
- ASSERT(FlagCreate());
-
- m_elListener = eina_list_remove(m_elListener, listener);
- }
- bool FlagConnected(void) {
- ASSERT(FlagCreate());
-#if 0
- if (usb_get_connected_device_number(USB_MASS_STORAGE) <= 0)
- return false;
-#endif
- return true;
- }
-};
-
-
-static CUsbConnectionListenerImpl refUCS;
-static int refUCSCnt = 0;
-
-
-bool CUsbConnectionListener::Create(void)
-{
- ASSERT(!FlagCreate());
-
- if (refUCSCnt == 0) {
- if (!refUCS.Create()) {
- return false;
- }
- }
- refUCSCnt++;
-
- refUCS.Add(this);
-
- m = (void*)1;
-
- return true;
-}
-
-
-void CUsbConnectionListener::Destroy(void)
-{
- ASSERT(FlagCreate());
-
- refUCS.Remove(this);
- refUCSCnt--;
- if (refUCSCnt == 0) {
- refUCS.Destroy();
- }
- m = NULL;
-}
-
-
-bool CUsbConnectionListener::FlagConnected(void)
-{
- ASSERT(FlagCreate());
-
- return refUCS.FlagConnected();
-}
-
-
-class CDbUpdateListenerImpl {
-private:
- Eina_List *m_elListener;
- bool m_created;
-
-private:
- static void sm_CbDbUpdated(media_content_error_e err, int pid,
- media_content_db_update_item_type_e update_item,
- media_content_db_update_type_e update_type,
- media_content_type_e media_type,
- char *uuid, char *path, char *mime_type,
- void *dt)
- {
- CDbUpdateListenerImpl* root = (CDbUpdateListenerImpl*)dt;
- if (root) {
- CDbUpdateListener::SEntity entity;
- entity.err = err;
- entity.pid = pid;
- entity.update_item = update_item;
- entity.update_type = update_type;
- entity.media_type = media_type;
- entity.uuid = uuid;
- entity.path = path;
- entity.mime_type = mime_type;
- root->t_OnDbUpdated(&entity);
- }
- }
-
-protected:
- virtual void t_OnDbUpdated(CDbUpdateListener::SEntity *entity) {
- Eina_List *l;
- void *obj;
-
- EINA_LIST_FOREACH(m_elListener, l, obj) {
- CDbUpdateListener* listener = (CDbUpdateListener*)obj;
- listener->OnUpdated(entity);
- }
- }
-
-public:
- CDbUpdateListenerImpl() {
- m_created = false;
- }
- ~CDbUpdateListenerImpl() {
- }
- bool FlagCreate(void) { return !!m_created; }
-
- bool Create(void) {
- ASSERT(!FlagCreate());
-
- m_elListener = NULL;
-
- if (media_content_set_db_updated_cb(sm_CbDbUpdated, this) != MEDIA_CONTENT_ERROR_NONE)
- return false;
-
- m_created = true;
- return true;
- }
- virtual void Destroy(void) {
- ASSERT(FlagCreate());
- media_content_unset_db_updated_cb();
- m_created = false;
- }
- void Add(CDbUpdateListener *listener) {
- ASSERT(FlagCreate() == true);
- m_elListener = eina_list_append(m_elListener, listener);
- }
- void Remove(CDbUpdateListener *listener) {
- ASSERT(FlagCreate() == true);
- m_elListener = eina_list_remove(m_elListener, listener);
- }
-};
-
-
-static CDbUpdateListenerImpl refDUS;
-static int refDUSCnt = 0;
-
-
-bool CDbUpdateListener::Create(void)
-{
- ASSERT(!FlagCreate());
-
- if (refDUSCnt == 0) {
- if (!refDUS.Create()) {
- return false;
- }
- }
- refDUSCnt++;
- refDUS.Add(this);
-
- m = (void*)1;
-
- return true;
-}
-
-
-void CDbUpdateListener::Destroy(void)
-{
- ASSERT(FlagCreate());
-
- refDUS.Remove(this);
-
- refDUSCnt--;
- if (refDUSCnt == 0) {
- refDUS.Destroy();
- }
-
- m = NULL;
-}