Update change log and spec for wrt-plugins-tizen_0.4.43
authorDongjin Choi <milkelf.choi@samsung.com>
Wed, 19 Jun 2013 12:35:45 +0000 (21:35 +0900)
committerDongjin Choi <milkelf.choi@samsung.com>
Wed, 19 Jun 2013 12:35:45 +0000 (21:35 +0900)
[model] REDWOOD
[binary_type] PDA
[customer] OPEN

[Issue#] CID 56765
[Problem] There is dereferencing a pointer.
[Solution] Fixed the dereferencing a pointer.

[Systeminfo] Fix TCT issue(storage property)
[Systeminfo] Chanage getDeviceCapabilities API code
[NBS] Fix TCT issue(manual tc)

[Issue#] N/A
[Problem] A crash and wrong sync statistics after syncing with the funambol server.
[Cause] Unexpected DS callback parameters and data from platform.
[Solution] Add defense codes and revise sync statistics handling routine.

[Issue] DCM 2017
[Problem] crash when callback is invoked.
[Cause] Appcontrol launch is failed, but remote app is launched.
[Solution] check event value.

[Issue] CID-60382
[Problem] Array compared against 0
[Cause] Comparing an array to null is not useful
[Solution] Check array is empty

[Issue] N/A
[Problem] Account Name and email sender address bug fix
[Cause] Account Name and email sender address bug fix
[Solution] Account Name and email sender address bug fix

[Issue] N/A
[Problem] remove assert function
[Cause] remove assert function
[Solution] remove assert function

[team] WebAPI
[request] N/A
[horizontal_expansion] N/A

39 files changed:
packaging/wrt-plugins-tizen.spec
src/Callhistory/CallHistory.cpp
src/DataControl/SqlDataControlConsumer.cpp
src/DataSync/DataSyncManager.cpp
src/DataSync/SyncStatistics.cpp
src/DataSync/SyncStatistics.h
src/Filesystem/EventResolve.cpp
src/Filesystem/EventResolve.h
src/Filesystem/INode.h
src/Filesystem/JSFilesystemManager.cpp
src/Filesystem/Manager.cpp
src/Filesystem/Node.cpp
src/Filesystem/Node.h
src/Filesystem/ResponseDispatcher.cpp
src/Messaging/Conversation.cpp
src/Messaging/ConverterMessage.cpp
src/Messaging/Email.cpp
src/Messaging/EmailService.cpp
src/Messaging/EmailUtils.cpp
src/Messaging/JSMessage.cpp
src/Messaging/MailSender.cpp
src/Messaging/MailSync.cpp
src/Messaging/Messaging.cpp
src/Messaging/MessagingController.cpp
src/Messaging/MessagingListener.cpp
src/Messaging/MessagingServiceManager.cpp
src/Messaging/NetworkStatus.cpp
src/Messaging/ReqReceiverMessage.cpp
src/Messaging/SyncNetworkStatus.cpp
src/NetworkBearerSelection/NetworkBearerSelection.cpp [changed mode: 0644->0755]
src/Systeminfo/CMakeLists.txt
src/Systeminfo/EventWatchSysteminfo.cpp
src/Systeminfo/EventWatchSysteminfo.h
src/Systeminfo/JSDeviceCapabilitiesInfo.cpp
src/Systeminfo/JSStorageInfo.cpp [changed mode: 0644->0755]
src/Systeminfo/JSStorageUnitInfo.cpp [new file with mode: 0755]
src/Systeminfo/JSStorageUnitInfo.h [new file with mode: 0755]
src/Systeminfo/Systeminfo.cpp
src/Systeminfo/SysteminfoPropertyInfo.h

index 2de7855..89e6274 100755 (executable)
@@ -1,7 +1,7 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.4.42
-Release:    2
+Version:    0.4.43
+Release:    0
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
index 1f7a309..9b4350b 100755 (executable)
@@ -769,8 +769,11 @@ void CallHistory::Watcher::ListenerCB(char* changes)
        while( tokenType != NULL )
        {
                tokenId = strtok( NULL, seps );
-               changeType = atoi((const char*)tokenType);
-               changeId = atoi((const char*)tokenId);
+
+               if(tokenType!=NULL)
+                       changeType = atoi((const char*)tokenType);
+               if(tokenId != NULL)
+                       changeId = atoi((const char*)tokenId);
 
 
                contacts_query_h query = NULL;
index fd22114..3a893e0 100644 (file)
@@ -162,6 +162,13 @@ static void sqldataControlSelectCallback(bundle* b, int request_code, appsvc_res
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
                LoggerE("Exception: " << ex.GetMessage());
+               
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+
                event->setExceptionCode(ex.getCode());
                event->setErrorMsg(ex.GetMessage());            
        }
@@ -241,6 +248,13 @@ static void sqldataControlInsertCallback(bundle* b, int request_code, appsvc_res
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
                LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+                       
                event->setExceptionCode(ex.getCode());
                event->setErrorMsg(ex.GetMessage());            
        }
@@ -314,6 +328,13 @@ static void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_res
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
                LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+               
                event->setExceptionCode(ex.getCode());
                event->setErrorMsg(ex.GetMessage());            
        }
@@ -385,6 +406,13 @@ static void sqldataControlUpdateCallback(bundle* b, int request_code, appsvc_res
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
                LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+                               
                event->setExceptionCode(ex.getCode());
                event->setErrorMsg(ex.GetMessage());            
        }
index ff33873..86bcaf7 100755 (executable)
@@ -397,7 +397,7 @@ static SyncStatistics::SyncStatus convertToSyncStatus(char* status)
                LoggerW("Error while converting a sync status.");
        }
 
-       return SyncStatistics::UNDEFINED_STATUS;
+       return SyncStatistics::NONE_STATUS;
 }
 
 void DataSyncManager::OnRequestReceived(const IEventAddProfilePtr &event)
@@ -1079,15 +1079,19 @@ void DataSyncManager::OnRequestReceived(const IEventGetLastSyncStatisticsPtr &ev
                        }
 
                        LoggerD("dbsynced: "<<statistics->dbsynced);
-                       statisticsPtr->setSyncStatus(convertToSyncStatus(statistics->dbsynced));
-                       statisticsPtr->setClientToServerTotal(statistics->client2server_total);
-                       statisticsPtr->setClientToServerAdded(statistics->client2server_nrofadd);
-                       statisticsPtr->setClientToServerUpdated(statistics->client2server_nrofreplace);
-                       statisticsPtr->setClientToServerRemoved(statistics->client2server_nrofdelete);
-                       statisticsPtr->setServerToClientTotal(statistics->server2client_total);
-                       statisticsPtr->setServerToClientAdded(statistics->server2client_nrofadd);
-                       statisticsPtr->setServerToClientUpdated(statistics->server2client_nrofreplace);
-                       statisticsPtr->setServerToClientRemoved(statistics->server2client_nrofdelete);
+                       if (statistics->dbsynced) {
+                               statisticsPtr->setSyncStatus(convertToSyncStatus(statistics->dbsynced));
+                               statisticsPtr->setClientToServerTotal(statistics->client2server_total);
+                               statisticsPtr->setClientToServerAdded(statistics->client2server_nrofadd);
+                               statisticsPtr->setClientToServerUpdated(statistics->client2server_nrofreplace);
+                               statisticsPtr->setClientToServerRemoved(statistics->client2server_nrofdelete);
+                               statisticsPtr->setServerToClientTotal(statistics->server2client_total);
+                               statisticsPtr->setServerToClientAdded(statistics->server2client_nrofadd);
+                               statisticsPtr->setServerToClientUpdated(statistics->server2client_nrofreplace);
+                               statisticsPtr->setServerToClientRemoved(statistics->server2client_nrofdelete);
+
+                               statisticsPtr->setLastSyncTime((long long int) (statistics->last_session_time));
+                       }
 
                        LoggerD("ClientToServerTotal: "<<statisticsPtr->getClientToServerTotal()<<", ServerToClientTotal: "<<statisticsPtr->getServerToClientTotal());
 
index 62b0c2d..c8a183b 100755 (executable)
@@ -23,7 +23,7 @@ namespace DataSync {
 
 SyncStatistics::SyncStatistics()
 {
-    m_syncStatus = UNDEFINED_STATUS;
+    m_syncStatus = NONE_STATUS;
     m_serviceType = SyncServiceInfo::UNDEFINED_SERVICE_TYPE;
     m_lastSyncTime = UNDEFILED_TIME;
        m_serverToClientTotal = 0;
index 1b54524..9dd5634 100755 (executable)
@@ -37,8 +37,7 @@ class SyncStatistics
                SUCCESS_STATUS,
                FAIL_STATUS,
                STOP_STATUS,
-               NONE_STATUS,
-               UNDEFINED_STATUS
+               NONE_STATUS
        } SyncStatus;
 
     SyncStatistics();
index 7750d8b..52572b1 100755 (executable)
@@ -22,6 +22,7 @@ namespace DeviceAPI {
 namespace Filesystem {
 EventResolve::EventResolve(const IPathPtr& path) : m_path(path)
 {
+       m_mode = "rw";
 }
 
 IPathPtr EventResolve::getPath() const
@@ -38,5 +39,15 @@ void EventResolve::setResult(const INodePtr& node)
 {
     m_node = node;
 }
+
+void EventResolve::setMode(const std::string &mode)
+{
+       m_mode = mode;
+}
+std::string EventResolve::getMode()
+{
+       return m_mode;
+}
+       
 } // Filesystem
 } // TizenApis
\ No newline at end of file
index b73f151..0f61331 100755 (executable)
@@ -55,9 +55,13 @@ class EventResolve : public WrtDeviceApis::Commons::IEvent<EventResolve>
      */
     void setResult(const INodePtr& node);
 
+    void setMode(const std::string &mode);
+    std::string getMode();
+
   private:
     IPathPtr m_path; ///< Path to the requested node.
     INodePtr m_node; ///< Resolved node.
+    std::string m_mode;
 };
 
 typedef DPL::SharedPtr<EventResolve> EventResolvePtr;
index 91ca0b0..e6b3611 100755 (executable)
@@ -176,6 +176,7 @@ class INode : public WrtDeviceApis::Commons::EventRequestReceiver<EventListNodes
     virtual void read(const EventReadTextPtr& event) = 0;
 
     virtual std::string toUri(int widgetId) const = 0;
+    virtual bool checkPermission(const IPathPtr& path, const std::string &mode, NodeType type) = 0;
 
   protected:
     INode();
index 2e98386..fbaa582 100644 (file)
@@ -543,15 +543,16 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
                virtualPath = converter->toString(reserveArguments[0]);
                LoggerD("virtualPath:[" << virtualPath << "]");
                int permissions = PERM_READ | PERM_WRITE;
+               std::string perm = "rw";
 
 
                
                if (argc > 3) {
-                       std::string perms = converter->toString(reserveArguments[3]);
-                       LoggerD("perms:[" << perms << "]");
-                       if (("r" != perms) && ("rw" != perms) && ("w" != perms) && ("a" != perms)) {
+                       perm = converter->toString(reserveArguments[3]);
+                       LoggerD("perms:[" << perm << "]");
+                       if (("r" != perm) && ("rw" != perm) && ("w" != perm) && ("a" != perm)) {
                                return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Invalid permission");
-                       } else if ("r" == perms) {
+                       } else if ("r" == perm) {
                                permissions = PERM_READ;
                        }
                }
@@ -570,6 +571,7 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
                EventGetNodeDataPtr data(new EventGetNodeData(permissions, cbm));
                EventResolvePtr event(new EventResolve(path));
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setMode(perm);
                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (data));
                FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
 
index 4fdf5f5..1518351 100644 (file)
@@ -421,7 +421,12 @@ bool Manager::matchFilters(const std::string& name,
 void Manager::OnRequestReceived(const EventResolvePtr& event)
 {
     try {
-        event->setResult(Node::resolve(event->getPath()));
+        INodePtr node = Node::resolve(event->getPath());
+        if (node->checkPermission(event->getPath(), event->getMode(), node->getType()) == false)
+        {
+            ThrowMsg(Commons::SecurityException, "Permission Denied Error");
+        }
+        event->setResult(node);
     }
     catch (const Commons::Exception& ex) 
     {
index 9e72030..30b07cd 100644 (file)
@@ -44,6 +44,79 @@ namespace DeviceAPI {
 namespace Filesystem {
 
 #define MAX_NODE_LENGTH 256
+bool Node::checkPermission(const IPathPtr &path, const std::string &mode, NodeType type)
+{
+       switch (type)
+       {
+       case NT_DIRECTORY:
+       {
+               DIR* dir = opendir(path->getFullPath().c_str());                
+               
+               if (!dir) 
+                       ThrowMsg(Commons::SecurityException, "Node has been deleted from platform.");
+                       
+               if (closedir(dir) != 0) 
+                       ThrowMsg(Commons::SecurityException, "Could not close platform node.");
+
+               LoggerD("open/close dir ok"); 
+                       
+
+               if (mode == "r")
+                       return true;
+
+               std::stringstream ss;
+               time_t now;
+               time(&now);
+               ss << now;
+               IPathPtr tempFilePath = IPath::create(path->getFullPath());
+               tempFilePath->append(ss.str());
+               try 
+               {
+                       createAsFileInternal(tempFilePath);
+                       removeAsFile(tempFilePath);
+               }
+               catch (const Commons::Exception& ex) 
+               {
+               LoggerE("Exception: " << ex.GetMessage());
+                       return false;
+               }
+                       
+               if (mode == "rw" || mode == "w"  || mode == "a")
+                       return true;
+               ThrowMsg(Commons::InvalidArgumentException, "invalid mode");
+       }
+       break;
+       case NT_FILE:
+       {
+               std::fstream stream;
+               std::ios_base::openmode modeBit = std::fstream::binary;
+
+               if (mode == "r")
+               {
+                       modeBit |=      std::fstream::in;
+               }
+               else if (mode == "rw" || mode == "w" || mode == "a")
+               {
+                       modeBit |=      std::fstream::app;
+               }
+               else 
+               {
+                       ThrowMsg(Commons::InvalidArgumentException, "invalid mode");
+               }
+               
+               stream.open(path->getFullPath().c_str(), modeBit);
+
+               if (stream.is_open())
+               {
+                       stream.close();
+                       return true;    
+               }
+               return false;
+       }
+       break;
+       }
+       return false;
+}
 
 INodePtr Node::resolve(const IPathPtr& path)
 {
@@ -56,7 +129,7 @@ INodePtr Node::resolve(const IPathPtr& path)
         switch (errno)
         {
         case EACCES:
-            ThrowMsg(Commons::PlatformException, "Node access denied");
+            ThrowMsg(Commons::SecurityException, "Node access denied");
             break;
         case ENOENT:
             ThrowMsg(Commons::NotFoundException, "Node does not exist");
index 233d7b1..2a59ddf 100755 (executable)
@@ -41,7 +41,9 @@ class Node : public INode,
     static INodePtr resolve(
             const IPathPtr& path);
 
+
   public:
+    bool checkPermission(const IPathPtr& path, const std::string &mode, NodeType type);
     IPathPtr getPath() const;
     NodeType getType() const;
     int getPermissions() const;
@@ -100,6 +102,7 @@ class Node : public INode,
 
     std::string toUri(int widgetId) const;
 
+
   private:
     IPathPtr m_path;
     NodeType m_type;
index 3eda79a..8c8673a 100644 (file)
@@ -87,7 +87,11 @@ void ResponseDispatcher::OnAnswerReceived(const EventResolvePtr& event)
                JSObjectRef jsException;
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
                        jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
-               } else {
+               } 
+               else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::UNKNOWN_ERROR, "PermissionDeniedError");
+               }
+               else {
                        jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown error");
                }
                data->getCallbackManager()->callOnError(jsException);
index b6181d9..78fc87b 100644 (file)
@@ -186,7 +186,7 @@ void Conversation::makeConversationFromThread(msg_struct_t msg_thread)
                                                char strNumber[MAX_ADDRESS_VAL_LEN] = {0,};
                                                msg_get_str_value(addr_list->msg_struct_info[toCount], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, MAX_ADDRESS_VAL_LEN);
 
-                                               if (strNumber != NULL)
+                                               if (strNumber[0] != '\0')
                                                {
                                                        m_to.push_back(strNumber);
                                                }
index 9a25644..bc742cf 100644 (file)
@@ -15,7 +15,6 @@
 // limitations under the License.
 //
 
-#include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Validator.h>
@@ -599,8 +598,6 @@ DeviceAPI::Filesystem::INodePtr ConverterMessage::toFilesystemNode(JSValueRef ar
 
 JSValueRef ConverterMessage::toFunctionOrNull(const JSValueRef& arg)
 {
-    Assert(arg && "Argument is NULL.");
-
     if (Validator(m_context).isCallback(arg)) {
         return arg;
     } else if (!JSValueIsNull(m_context, arg) ) {
@@ -611,8 +608,6 @@ JSValueRef ConverterMessage::toFunctionOrNull(const JSValueRef& arg)
 
 JSValueRef ConverterMessage::toFunction(const JSValueRef& arg)
 {
-    Assert(arg && "Argument is NULL.");
-
     if (Validator(m_context).isCallback(arg)) {
         return arg;
     } else if (JSValueIsNull(m_context, 
index f2f38e7..1b666c2 100644 (file)
@@ -22,7 +22,6 @@
 #include <ctime>
 #include <email-types.h>
 #include <email-api.h>
-#include <dpl/assert.h>
 #include <dpl/scoped_fclose.h>
 #include <dpl/scoped_ptr.h>
 #include <Commons/Exception.h>
@@ -437,7 +436,10 @@ void Email::readHeader()
 {
     LOG_ENTER
 
-    Assert(m_mail && "Header is NULL.");
+    if (!m_mail) {
+        LoggerE("Header is NULL");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
 
     if (m_mail->subject) {
         setSubject(m_mail->subject);
@@ -528,7 +530,10 @@ void Email::readHeader()
 void Email::readBody() {
        LOG_ENTER
 
-       Assert(m_mail && "Body is NULL.");
+    if (!m_mail) {
+        LoggerE("Body is NULL");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
 
        if (m_mail->file_path_plain) {
                LoggerD("m_mail->file_path_plain : " << m_mail->file_path_plain);
@@ -859,11 +864,17 @@ void Email::updateMessage()
                LoggerW("email_get_attachment_data_list [" << error << "]");
        }
 
-       error = email_get_meeting_request(m_mail->mail_id, &meeting_req);
-       if (EMAIL_ERROR_NONE != error) {
-               LoggerW("email_get_meeting_request() failed [" << error <<"]");
-       }
+       LoggerW("meeting_request_status " << m_mail->meeting_request_status);
 
+       if( m_mail->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
+               || m_mail->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
+               || m_mail->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST)
+       {
+               error = email_get_meeting_request(m_mail->mail_id, &meeting_req);
+               if (EMAIL_ERROR_NONE != error) {
+                       LoggerW("email_get_meeting_request() failed [" << error <<"]");
+               }
+       }
        error = email_update_mail( m_mail.Get(), attachment, attachmentCount, meeting_req, 0);
        if (EMAIL_ERROR_NONE != error) {
                LoggerW("Nothing to update or error. [" << error << "]");
@@ -873,7 +884,8 @@ void Email::updateMessage()
        {
        
                updateAttachments();
-               
+
+/*             
                email_mail_data_t* result = NULL;
                
                error = email_get_mail_data(m_mail->mail_id, &result);
@@ -907,6 +919,7 @@ void Email::updateMessage()
                                LoggerW("email_free_mail_data error. [" << error << "]");
                        }
                }
+*/
        }
 
        if(meeting_req) {
index adbf93c..8ded66b 100644 (file)
@@ -18,7 +18,6 @@
 #include <string>
 #include <sstream>
 
-#include <dpl/assert.h>
 #include <dpl/scoped_free.h>
 
 #include <email-api.h>
@@ -134,7 +133,10 @@ email_mailbox_t* getMailboxByType(int accountId,
 int addMail(email_mail_data_t* mail, email_attachment_data_t* attachment)
 {
     LOG_ENTER
-    Assert(mail);
+    if (!mail) {
+        LoggerE("mail is NULL");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
 
     int error = 0;
     if (!mail->mailbox_id)
index f13f911..0cacc8c 100755 (executable)
@@ -49,7 +49,7 @@ std::string formatAddress(const std::string& address,
 
     std::stringstream ss;
     if (!name.empty()) {
-        ss << "\"" << name << "\" ";
+        ss << "\"" << name << "\"";
     }
     ss << "<" << address << ">";
 
@@ -59,8 +59,17 @@ std::string formatAddress(const std::string& address,
 std::string formatAddressLine(const Recipients& recipients)
 {
     std::string result;
-    for (size_t i = 0; i < recipients.getRecipientSize(); ++i) {
-        result += formatAddress(recipients.getRecipient(i)) + ";";
+    size_t tempSize = recipients.getRecipientSize();
+
+    for (size_t i = 0; i < tempSize; ++i) {
+        if(i != tempSize-1)
+        {
+            result += formatAddress(recipients.getRecipient(i)) + ";";
+        }
+        else
+        {
+            result += formatAddress(recipients.getRecipient(i));
+        }
     }
     return result;
 }
index 0b4f9f1..be7c71a 100644 (file)
@@ -15,7 +15,6 @@
 // limitations under the License.
 //
 
-#include <dpl/assert.h>
 #include "MessageFactory.h"
 #include "MessagePriority.h"
 #include <CommonsJavaScript/JSCallbackManager.h>
index dc41a55..59172e0 100644 (file)
@@ -22,7 +22,6 @@
 #include <email-api-init.h>
 #include <email-api-account.h>
 
-#include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include <Commons/ThreadPool.h>
 #include "ReqReceiverMessage.h"
@@ -52,7 +51,10 @@ MailSender& MailSender::getInstance()
 
 int MailSender::send(const IEmailPtr& mail)
 {
-    Assert(mail && "Mail must not be NULL.");
+    if (!mail) {
+        LoggerE("mail is NULL");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
 
     int mailId = mail->convertId(mail->getIdRef());
     LoggerD("send mailId = " << mailId);
index 5852d86..b716596 100644 (file)
@@ -22,7 +22,6 @@
 #include <email-api-init.h>
 #include <email-api-account.h>
 
-#include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include <Commons/ThreadPool.h>
 #include "ReqReceiverMessage.h"
@@ -154,8 +153,6 @@ int MailSync::downloadBody( const IEmailPtr& mail )
 
 void MailSync::cancelDownloadBody(int handle)
 {
-       Assert(handle > -1);
-
        SyncRequestIterator it = m_SyncRequests.find(handle);
        if ( m_SyncRequests.end() != it)
        {
@@ -173,7 +170,6 @@ void MailSync::cancelDownloadBody(int handle)
 
 void MailSync::cancelDownloadAttachment(int handle)
 {
-       Assert(handle > -1);
 
        SyncRequestIterator it = m_SyncRequests.find(handle);
        if ( m_SyncRequests.end() != it)
@@ -304,7 +300,6 @@ int MailSync::syncAccountInternal( const IMessagingServicePtr& messagingService,
 void MailSync::syncAccountCancel(const int handle)
 {
        LoggerD("sync cancel");
-       Assert(handle > -1);
 
        SyncRequestIterator it = m_SyncRequests.find(handle);
        if ( m_SyncRequests.end() != it)
@@ -363,7 +358,6 @@ int MailSync::syncFolder(const IMessagingServicePtr& messagingService, const int
 void MailSync::syncFolderCancel(const int handle)
 {
        LoggerD("sync Folder Cancel");
-       Assert(handle > -1);
 
        SyncRequestIterator it = m_SyncRequests.find(handle);
        if ( m_SyncRequests.end() != it)
@@ -667,7 +661,10 @@ int MailSync::downloadBodyInternal( const IEmailPtr& mail, int account_id)
 int MailSync::downloadAttachmentInternal(const IEmailPtr& mail, int account_id, const IAttachmentPtr& attachment)
 {
        LoggerD("downloadAttachmentInternal");
-       Assert(mail);
+       if (!mail) {
+               LoggerE("mail is NULL");
+               Throw(WrtDeviceApis::Commons::PlatformException);
+       }
        
        int err = 0;
        int nth = 0;
index 8b636cc..57d943e 100644 (file)
@@ -854,13 +854,13 @@ vector<EmailAccountInfo> Messaging::getEmailAccounts() const
                }
 
                vector<EmailAccountInfo> result;
-               for (int i = 0; i < count; ++i) 
+               for (int i = 0; i < count; ++i)
                {
-                       if(accounts[i].incoming_server_user_name  !=  NULL)
+                       if(accounts[i].user_display_name  !=  NULL)
                        {
                                LoggerE("server user name is NULL");
                                EmailAccountInfo account(accounts[i].account_id,
-                                                                                       accounts[i].incoming_server_user_name,
+                                                                                       accounts[i].user_display_name,
                                                                                        accounts[i].user_email_address);
                                result.push_back(account);
                        }
index 4986daf..5ff0d81 100644 (file)
@@ -281,7 +281,11 @@ void MessagingController::OnAnswerReceived(const EventSendMessagePtr& event)
        JSValueRef error = NULL;
        EventSendMessagePrivateDataPtr privateData = 
                DPL::StaticPointerCast<EventSendMessagePrivateData>(event->getPrivateData());
-       Assert(NULL != privateData);
+       if(!privateData)
+       {
+               LoggerE("no privateData");
+               return;
+       }
 
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = privateData->getCallbackManager();
        MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
@@ -289,7 +293,6 @@ void MessagingController::OnAnswerReceived(const EventSendMessagePtr& event)
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr recipientCallbackManager = privateData->getRecipientCallbackManager();
 
        JSContextRef context = callbackManager->getContext();
-       Assert(NULL != context);
           
     if (WrtDeviceApis::Commons::ExceptionCodes::None != event->getExceptionCode()) {
         switch (event->getExceptionCode()) {
index f37431b..fdf73df 100644 (file)
@@ -16,7 +16,6 @@
 //
 
 #include <vector>
-#include <dpl/assert.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 
 #include <IFilter.h>
@@ -74,11 +73,14 @@ void MessagingListener::OnAnswerReceived(
 {
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
         DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
-    Assert(NULL != callbackManager);
+    if(!callbackManager)
+    {
+        LoggerE("no callbackManager");
+        return;
+    }
     LoggerD("thread=" << DPL::Thread::GetCurrentThread());
 
     JSContextRef context = callbackManager->getContext();
-    Assert(NULL != context);
 
     MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
 
@@ -130,11 +132,15 @@ void MessagingListener::OnAnswerReceived(
 {
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
         DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
-    Assert(NULL != callbackManager);
+    if(!callbackManager)
+    {
+        LoggerE("no callbackManager");
+        return;
+    }
+
     LoggerD("thread=" << DPL::Thread::GetCurrentThread());
 
     JSContextRef context = callbackManager->getContext();
-    Assert(NULL != context);
 
     MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
 
@@ -192,11 +198,14 @@ void MessagingListener::OnAnswerReceived(
 {
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
         DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
-    Assert(NULL != callbackManager);
+    if(!callbackManager)
+    {
+        LoggerE("no callbackManager");
+        return;
+    }
     LoggerD("thread=" << DPL::Thread::GetCurrentThread());
 
     JSContextRef context = callbackManager->getContext();
-    Assert(NULL != context);
 
     MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
 
@@ -242,11 +251,14 @@ void MessagingListener::OnAnswerReceived(
 {
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
         DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
-    Assert(NULL != callbackManager);
+    if(!callbackManager)
+    {
+        LoggerE("no callbackManager");
+        return;
+    }
     LoggerD("thread=" << DPL::Thread::GetCurrentThread());
 
     JSContextRef context = callbackManager->getContext();
-    Assert(NULL != context);
 
     MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
 
@@ -292,11 +304,14 @@ void MessagingListener::OnAnswerReceived(
 {
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
         DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
-    Assert(NULL != callbackManager);
+    if(!callbackManager)
+    {
+        LoggerE("no callbackManager");
+        return;
+    }
     LoggerD("thread=" << DPL::Thread::GetCurrentThread());
 
     JSContextRef context = callbackManager->getContext();
-    Assert(NULL != context);
 
     Try
     {
@@ -341,9 +356,12 @@ void MessagingListener::OnAnswerReceived(const EventQueryConversationsPtr& event
        LoggerD("enter");
 
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
-
+       if(!callbackManager)
+       {
+               LoggerE("no callbackManager");
+               return;
+       }
        JSContextRef context = callbackManager->getContext();
-       Assert(NULL != context);
 
        MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
 
@@ -404,9 +422,13 @@ void MessagingListener::OnAnswerReceived(const EventDeleteConversationsPtr& even
 {
        LoggerD("enter");
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
+    if(!callbackManager)
+    {
+        LoggerE("no callbackManager");
+        return;
+    }
 
        JSContextRef context = callbackManager->getContext();
-       Assert(NULL != context);
 
        MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
        
@@ -455,9 +477,13 @@ void MessagingListener::OnAnswerReceived(const EventQueryFoldersPtr& event)
        LoggerD("enter");
 
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
+       if(!callbackManager)
+       {
+               LoggerE("no callbackManager");
+               return;
+       }
 
        JSContextRef context = callbackManager->getContext();
-       Assert(NULL != context);
 
        MessageAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
 
index db34065..27fe93e 100644 (file)
@@ -61,8 +61,8 @@ std::vector<EmailAccountInfo> MessagingServiceManager::getEmailAccounts()
                        {
                                std::stringstream stream;
                                for (int i = 0; i < count; ++i) {
-                                       stream << "[" << accounts[i].account_name << "] " << accounts[i].incoming_server_user_name;
-                                       LoggerD("account ID :" << accounts[i].account_id << "Name :" << accounts[i].incoming_server_user_name << "Addr :" << accounts[i].user_email_address );
+                                       stream << "[" << accounts[i].account_name << "] " << accounts[i].user_display_name;
+                                       LoggerD("account ID :" << accounts[i].account_id << "Name :" << accounts[i].user_display_name << "Addr :" << accounts[i].user_email_address );
                                        EmailAccountInfo account(accounts[i].account_id, stream.str(), accounts[i].user_email_address );
                                        result.push_back(account);
                                        stream.str("");
index f99853a..ba187b4 100755 (executable)
@@ -15,7 +15,7 @@
 // limitations under the License.
 //
 
-#include <dpl/assert.h>
+#include <Logger.h>
 #include <Commons/Exception.h>
 #include "NetworkStatus.h"
 
@@ -29,7 +29,10 @@ namespace Messaging {
 
 NetworkStatus::NetworkStatus(const DBus::MessagePtr& message)
 {
-    Assert(message->getInterface() == DBUS_INTERFACE_NETWORK_STATUS);
+    LoggerD("enter : "  << message->getInterface());
+    if (message->getInterface() != DBUS_INTERFACE_NETWORK_STATUS) {
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
     initialize(message);
 }
 
index dcddea7..46181af 100644 (file)
@@ -245,8 +245,8 @@ void ReqReceiverMessage::OnRequestReceived(const EventAddDraftMessagePtr& event)
                                                {
                                                        int index = (int)event->getIndex();
                                                        EmailAccountInfo account(accounts[index-1].account_id,
-                                                               accounts[index-1].incoming_server_user_name,
-                                                               accounts[index-1].user_email_address );                                         
+                                                               accounts[index-1].user_display_name,
+                                                               accounts[index-1].user_email_address );
                                                        email->setEmailAccount(account);
                                                }
                                        }
index 0974ddc..27bf1d1 100644 (file)
@@ -15,7 +15,6 @@
 // limitations under the License.
 //
 
-#include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include "SyncNetworkStatus.h"
 #include <Logger.h>
@@ -30,8 +29,10 @@ namespace Messaging {
 
 SyncNetworkStatus::SyncNetworkStatus(const DBus::MessagePtr& message)
 {
-       LoggerD("enter : "  << message->getInterface());
-       Assert(message->getInterface() == DBUS_INTERFACE_NETWORK_STATUS);
+    LoggerD("enter : "  << message->getInterface());
+    if (message->getInterface() != DBUS_INTERFACE_NETWORK_STATUS) {
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
     initialize(message);
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 39cdf2a..9d4fa1a
@@ -36,6 +36,11 @@ static void connection_state_changed_callback(connection_profile_state_e state,
     LoggerD("enter");
     if(user_data != NULL) {
         LoggerD("Callback registration Succeeded");
+        if (state == CONNECTION_PROFILE_STATE_ASSOCIATION) {
+            LoggerD("association state");
+            return;
+        }
+
         NewtorkBearerSelectionPendingEvent *pendingEvent = (NewtorkBearerSelectionPendingEvent *)user_data;
         NetworkBearerSelection *networkBearerSelection = (NetworkBearerSelection *)pendingEvent->getThisObject();
         EventNetworkBearerSelectionPtr event = pendingEvent->getEvent();
@@ -46,8 +51,6 @@ static void connection_state_changed_callback(connection_profile_state_e state,
             networkBearerSelection->makeCallback(event, CONNECTION_STATE_CONNECTED);
         }
     
-        delete pendingEvent;
-        pendingEvent = NULL;
         user_data = NULL;
     }
 }
@@ -297,9 +300,14 @@ void NetworkBearerSelection::registStateChangeListener(const EventNetworkBearerS
     LoggerD("hostAddr : " << hostAddr);
 
     NewtorkBearerSelectionPendingEvent *pendingEvent = new NewtorkBearerSelectionPendingEvent((void *)this, event);
-    connection_profile_set_state_changed_cb(m_profileHandle, connection_state_changed_callback, pendingEvent);
+    if (connection_profile_set_state_changed_cb(m_profileHandle, connection_state_changed_callback, pendingEvent) != CONNECTION_ERROR_NONE) {
+        LoggerE("Callback register is failed.");
+        delete pendingEvent;
+        pendingEvent = NULL;        
+    } else {
     connection_add_route(m_connectionHandle, interfaceName, hostAddr);
 }
+}
 
 void NetworkBearerSelection::deregistStateChangeListener(const EventNetworkBearerReleasePtr &event)
 {
index e33d773..53f8287 100755 (executable)
@@ -33,6 +33,7 @@ SET(SRCS_IMPL
        Systeminfo.cpp
        JSDisplayInfo.cpp
        JSStorageInfo.cpp
+       JSStorageUnitInfo.cpp
        JSCpuInfo.cpp
        JSWifiNetworkInfo.cpp
        JSCellularNetworkInfo.cpp
index c64e5b7..174f0c8 100755 (executable)
@@ -30,7 +30,6 @@ namespace {
 
 static Eina_Bool timeout_timer_cb(void* data)
 {
-    LoggerD("enter");
     EventWatchSysteminfo *event = static_cast<EventWatchSysteminfo *> (data);
     event->timeoutWatch();
     return ECORE_CALLBACK_RENEW;
@@ -38,7 +37,7 @@ static Eina_Bool timeout_timer_cb(void* data)
 
 }
 
-#define MAX_STORAGE_CNT 3
+#define MAX_STORAGE_CNT 2
 DPL::Atomic EventWatchSysteminfo::m_uniqId = 1;
 
 EventWatchSysteminfo::EventWatchSysteminfo() : m_id(m_uniqId)
@@ -116,6 +115,7 @@ void EventWatchSysteminfo::processGetValue()
     JSStringRef propertyName = NULL;
     std::string key;
     JSObjectRef object = NULL;
+    JSValueRef value = NULL;
     double level = 0.0, brightness = 0.0, load = 0.0;
     bool isCharging = false;
     double capacity[MAX_STORAGE_CNT];
@@ -162,8 +162,14 @@ void EventWatchSysteminfo::processGetValue()
                     Throw(WrtDeviceApis::Commons::Exception);
                 }
 
+                key = "units";
+                object = JSValueToObject(context, lastValue, NULL);
+                propertyName = JSStringCreateWithUTF8CString(key.c_str());
+                value = JSObjectGetProperty(context, object, propertyName, NULL);
+
                 for (int i=0; i<m_tmpStorageCnt; i++) {
-                    lastValueList[i] = JSGetArrayElement(context, JSValueToObject(context, lastValue, NULL), i);
+
+                    lastValueList[i] = JSGetArrayElement(context, JSValueToObject(context, value, NULL), i);
                     
                     key = "capacity";
                     object = JSValueToObject(context, lastValueList[i], NULL);
@@ -249,8 +255,13 @@ void EventWatchSysteminfo::processGetValue()
                 Throw(Exception);
             }
             
+            key = "units";
+            object = JSValueToObject(context, tmpValue, NULL);
+            propertyName = JSStringCreateWithUTF8CString(key.c_str());
+            value = JSObjectGetProperty(context, object, propertyName, NULL);
+
             for (int i=0; i<m_tmpStorageCnt; i++) {
-                tmpValueList[i] = JSGetArrayElement(context, JSValueToObject(context, tmpValue, NULL), i);
+                tmpValueList[i] = JSGetArrayElement(context, JSValueToObject(context, value, NULL), i);
                 key = "capacity";
                 object = JSValueToObject(context, tmpValueList[i], NULL);
                 propertyName = JSStringCreateWithUTF8CString(key.c_str());
index 680de46..075e8ac 100755 (executable)
@@ -49,7 +49,7 @@ struct StoragePropertyValue {
 struct PropertyValue {
     BatteryPropertyValue batterInfo;
     CpuPropertyValue     cpuInfo;
-    StoragePropertyValue storageInfo[3];
+    StoragePropertyValue storageInfo[2];
 };
 
 class EventWatchSysteminfo : public WrtDeviceApis::Commons::IEvent<EventWatchSysteminfo>
index 839ae61..4c837d9 100755 (executable)
@@ -788,8 +788,7 @@ JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectR
             if(system_info_get_platform_bool("tizen.org/feature/input.keys.back", &inputKeyBack) == SYSTEM_INFO_ERROR_NONE) {
                 deviceCapabilitiesInfo->inputKeyBack = inputKeyBack;
             } else {
-                LoggerE("fail get value");
-                Throw(WrtDeviceApis::Commons::Exception);
+                return JSValueMakeUndefined(context);
             }
             return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyBack);
         } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_INPUT_KEY_OPTION)) {
@@ -797,8 +796,7 @@ JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectR
             if(system_info_get_platform_bool("tizen.org/feature/input.keys.menu", &inputKeyMenu) == SYSTEM_INFO_ERROR_NONE) {
                 deviceCapabilitiesInfo->inputKeyMenu = inputKeyMenu;
             } else {
-                LoggerE("fail get value");
-                Throw(WrtDeviceApis::Commons::Exception);
+                return JSValueMakeUndefined(context);
             }
             return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyMenu);
         }
old mode 100644 (file)
new mode 100755 (executable)
index f75fcd5..029a084
@@ -16,6 +16,7 @@
 //
 
 #include <memory>
+#include "JSStorageUnitInfo.h"
 #include "JSStorageInfo.h"
 #include <Logger.h>
 
@@ -25,11 +26,7 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace WrtDeviceApis::Commons;
 
 namespace {
-const char* STORAGE_TYPE_PROPERTY = "type";
-const char* STORAGE_CAPACITY_PROPERTY = "capacity";
-const char* STORAGE_AVAILCAPA_PROPERTY = "availableCapacity";
-const char* STORAGE_REMOVEABLE_PROPERTY = "isRemoveable";
-const char* STORAGE_REMOVABLE_PROPERTY = "isRemovable";
+const char* STORAGE_UNITS_PROPERTY = "units";
 } 
 
 JSClassRef JSStorageInfo::m_classRef = NULL;
@@ -55,11 +52,7 @@ JSClassDefinition JSStorageInfo::m_classInfo = {
 };
 
 JSStaticValue JSStorageInfo::m_properties[] = {
-    { STORAGE_TYPE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { STORAGE_CAPACITY_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { STORAGE_AVAILCAPA_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { STORAGE_REMOVEABLE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { STORAGE_REMOVABLE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { STORAGE_UNITS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
     { 0, 0, 0, 0 }
 };
 
@@ -113,16 +106,29 @@ JSValueRef JSStorageInfo::getProperty(JSContextRef context, JSObjectRef object,
     {
         StoragePropertiesPtr storageInfo = priv->getObject();
         Converter convert(context);
-        if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_TYPE_PROPERTY)) {
-            return convert.toJSValueRef(storageInfo->type);
-        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_CAPACITY_PROPERTY)) {
-            return JSValueMakeNumber(context, storageInfo->capacity);
-        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_AVAILCAPA_PROPERTY)) {
-            return JSValueMakeNumber(context, storageInfo->availableCapacity);            
-        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_REMOVEABLE_PROPERTY)) {
-            return convert.toJSValueRef(storageInfo->isRemoveable);
-        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_REMOVABLE_PROPERTY)) {
-            return convert.toJSValueRef(storageInfo->isRemovable);
+        std::vector <JSObjectRef> storagelist;
+        StorageUnitPropertiesPtr internal(new StorageUnitProperties());
+        StorageUnitPropertiesPtr sdcard(new StorageUnitProperties());
+
+        if (storageInfo->cnt > 0) {
+            internal->type = storageInfo->units[0].type;
+            internal->capacity = storageInfo->units[0].capacity;
+            internal->availableCapacity = storageInfo->units[0].availableCapacity;
+            internal->isRemoveable = storageInfo->units[0].isRemoveable;
+            internal->isRemovable = storageInfo->units[0].isRemovable;
+            storagelist.push_back(JSStorageUnitInfo::createJSObject(context, internal));
+        }
+        if (storageInfo->cnt > 1) {
+            sdcard->type = storageInfo->units[1].type;
+            sdcard->capacity = storageInfo->units[1].capacity;
+            sdcard->availableCapacity = storageInfo->units[1].availableCapacity;
+            sdcard->isRemoveable = storageInfo->units[1].isRemoveable;
+            sdcard->isRemovable = storageInfo->units[1].isRemovable;
+            storagelist.push_back(JSStorageUnitInfo::createJSObject(context, sdcard));
+        }
+
+        if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNITS_PROPERTY)) {
+            return JSObjectMakeArray(context, storageInfo->cnt, storagelist.data(), NULL);
         }
     }
     Catch(Exception)
diff --git a/src/Systeminfo/JSStorageUnitInfo.cpp b/src/Systeminfo/JSStorageUnitInfo.cpp
new file mode 100755 (executable)
index 0000000..797d1b9
--- /dev/null
@@ -0,0 +1,135 @@
+//
+// 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 <memory>
+#include "JSStorageUnitInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* STORAGE_UNIT_TYPE_PROPERTY = "type";
+const char* STORAGE_UNIT_CAPACITY_PROPERTY = "capacity";
+const char* STORAGE_UNIT_AVAILCAPA_PROPERTY = "availableCapacity";
+const char* STORAGE_UNIT_REMOVEABLE_PROPERTY = "isRemoveable";
+const char* STORAGE_UNIT_REMOVABLE_PROPERTY = "isRemovable";
+} 
+
+JSClassRef JSStorageUnitInfo::m_classRef = NULL;
+
+JSClassDefinition JSStorageUnitInfo::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    "storageunitinfo",
+    0,
+    m_properties,
+    NULL,
+    Initialize,
+    Finalize,
+    hasProperty,
+    getProperty,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+
+JSStaticValue JSStorageUnitInfo::m_properties[] = {
+    { STORAGE_UNIT_TYPE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { STORAGE_UNIT_CAPACITY_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { STORAGE_UNIT_AVAILCAPA_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { STORAGE_UNIT_REMOVEABLE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { STORAGE_UNIT_REMOVABLE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSStorageUnitInfo::getClassRef()
+{
+    if (!m_classRef) {
+        m_classRef = JSClassCreate(&m_classInfo);
+    }
+    return m_classRef;
+}
+
+const JSClassDefinition* JSStorageUnitInfo::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+void JSStorageUnitInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSStorageUnitInfo::Finalize(JSObjectRef object)
+{
+    LoggerD("Entered");
+    JSStorageUnitPriv* priv = static_cast<JSStorageUnitPriv*>(JSObjectGetPrivate(object));
+    JSObjectSetPrivate(object, NULL);
+    LoggerD("Deleting StorageUnitInfo object");
+    delete priv;
+}
+
+bool JSStorageUnitInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+    return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSStorageUnitInfo::createJSObject(JSContextRef context, const StorageUnitPropertiesPtr storageUnitInfo)
+{
+    JSStorageUnitPriv *priv = new JSStorageUnitPriv(context, storageUnitInfo);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSStorageUnitInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    LoggerD("Enter");
+    JSStorageUnitPriv *priv = static_cast<JSStorageUnitPriv*>(JSObjectGetPrivate(object));
+    if (NULL == priv) {
+        LoggerE("Private object not set.");
+        return JSValueMakeUndefined(context);
+    }
+
+    Try
+    {
+        StorageUnitPropertiesPtr storageUnitInfo = priv->getObject();
+        Converter convert(context);
+        if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_TYPE_PROPERTY)) {
+            return convert.toJSValueRef(storageUnitInfo->type);
+        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_CAPACITY_PROPERTY)) {
+            return JSValueMakeNumber(context, storageUnitInfo->capacity);
+        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_AVAILCAPA_PROPERTY)) {
+            return JSValueMakeNumber(context, storageUnitInfo->availableCapacity);            
+        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_REMOVEABLE_PROPERTY)) {
+            return convert.toJSValueRef(storageUnitInfo->isRemoveable);
+        } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_REMOVABLE_PROPERTY)) {
+            return convert.toJSValueRef(storageUnitInfo->isRemovable);
+        }
+    }
+    Catch(Exception)
+    {
+        LoggerE("Exception: " << _rethrown_exception.GetMessage());
+    }
+    return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/src/Systeminfo/JSStorageUnitInfo.h b/src/Systeminfo/JSStorageUnitInfo.h
new file mode 100755 (executable)
index 0000000..f435286
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_STORAGE_UNIT_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_STORAGE_UNIT_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<StorageUnitPropertiesPtr>::Type       JSStorageUnitPriv;
+
+class JSStorageUnitInfo
+{
+  public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    static JSObjectRef createJSObject(JSContextRef context, const StorageUnitPropertiesPtr storageUnitInfo);
+
+  private:
+    static void Initialize(JSContextRef context, JSObjectRef object);
+    static void Finalize(JSObjectRef object);
+    static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+    static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+    static JSStaticValue m_properties[];
+    static JSClassRef m_classRef;
+    static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
index d13c0d3..eeb804f 100755 (executable)
@@ -387,17 +387,11 @@ void Systeminfo::getWatchValue(const int watchType)
         for (EventStorageList::iterator it = eventList.begin(); it != eventList.end(); it++) {
         int storageCnt = 1;
         int sdcardState = 0;
-        int usbhostState = 0;
         if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
             if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED) {
                 storageCnt++;
             }
         }
-        if(vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &usbhostState) == 0) {
-            if(usbhostState == VCONFKEY_SYSMAN_USB_HOST_CONNECTED) {
-                storageCnt++;
-            }
-        }
         LoggerD("storage cnt : " << storageCnt);
             (*it)->getWatchValue(storageCnt);
         }
@@ -1065,57 +1059,36 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Cpu) {
 PROPERTY_GET_SYSTEMINFO_DEFINITION(Storage) {
     Converter converter(context);
     int sdcardState=0;
-    int usbhostState=0;
-    int storageCnt=0;
     struct statfs fs;
-    StoragePropertiesPtr internal(new StorageProperties());
-    StoragePropertiesPtr mmc(new StorageProperties());
-    StoragePropertiesPtr usbhost(new StorageProperties());
-    std::vector <JSObjectRef> storagelist;
     
     if (statfs(STORAGE_INTERNAL_PATH, &fs) < 0) {
+        // make exception
         return JSValueMakeNull(context);
     }
-
-    internal->type = "INTERNAL";
-    internal->capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
-    internal->availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
-    internal->isRemoveable = false;
-    internal->isRemovable = false;
-    storagelist.push_back(JSStorageInfo::createJSObject(context, internal));
-    storageCnt++;
-
-    if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0){
+    StoragePropertiesPtr storagePtr(new StorageProperties());
+    storagePtr->units[0].type = "INTERNAL";
+    storagePtr->units[0].capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
+    storagePtr->units[0].availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
+    storagePtr->units[0].isRemoveable = false;
+    storagePtr->units[0].isRemovable = false;
+    storagePtr->cnt = 1;
+    LoggerD("type : " << storagePtr->units[0].type);
+    if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
         if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED){
-            storageCnt++;
             if (statfs(STORAGE_SDCARD_PATH, &fs) < 0) {
                 return JSValueMakeNull(context);
             }
-            mmc->type = "MMC";
-            mmc->capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
-            mmc->availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
-            mmc->isRemoveable = true;
-            mmc->isRemovable = true;
-            storagelist.push_back(JSStorageInfo::createJSObject(context, mmc));
+            storagePtr->units[1].type = "MMC";
+            storagePtr->units[1].capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
+            storagePtr->units[1].availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
+            storagePtr->units[1].isRemoveable = false;
+            storagePtr->units[1].isRemovable = false;
+            storagePtr->cnt = 2;
+            LoggerD("type : " << storagePtr->units[1].type);            
         }
     }
+    return JSStorageInfo::createJSObject(context, storagePtr);  
 
-    if(vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &usbhostState) == 0) {
-        if(usbhostState == VCONFKEY_SYSMAN_USB_HOST_CONNECTED) {
-            storageCnt++;
-            if (statfs(STORAGE_USBHOST_PATH, &fs) < 0)    {
-                return JSValueMakeNull(context);
-            }
-            usbhost->type = "USB_HOST";
-            usbhost->capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
-            usbhost->availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
-            usbhost->isRemoveable = true;
-            usbhost->isRemovable = true;
-            storagelist.push_back(JSStorageInfo::createJSObject(context, usbhost));
-        }
-    }
-
-    return JSObjectMakeArray(context, storageCnt, storagelist.data(), NULL);
 }
 
 PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
@@ -1325,7 +1298,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(CellularNetwork) {
             connection_profile_destroy(profileHandle);
         }
     }
-
+  
     tapiHandle = tel_init(0);
     
     if (tapiHandle != NULL) {
index f08aea6..6aeff39 100755 (executable)
@@ -203,7 +203,7 @@ struct CpuProperties
     }
 };
 
-struct StorageProperties
+struct StorageUnitProperties
 {
        std::string             type;
        unsigned long long      capacity;
@@ -211,7 +211,7 @@ struct StorageProperties
        bool                    isRemoveable;
        bool                    isRemovable;
 
-       StorageProperties():
+       StorageUnitProperties():
                type("UNKNOWN"),
                capacity(0),
                availableCapacity(0),
@@ -221,6 +221,18 @@ struct StorageProperties
        }
 };
 
+struct StorageProperties
+{
+    StorageUnitProperties   units[2];
+    unsigned long           cnt;
+
+    StorageProperties():
+        cnt(0)
+    {
+    }
+};
+
+
 struct DisplayProperties
 {
        unsigned long  resolutionWidth;
@@ -374,6 +386,7 @@ struct PeripheralProperties
 typedef DPL::SharedPtr<DeviceCapabilitiesProperties> DeviceCapabilitiesPropertiesPtr;
 typedef DPL::SharedPtr<BatteryProperties> BatteryPropertiesPtr;
 typedef DPL::SharedPtr<CpuProperties> CpuPropertiesPtr;
+typedef DPL::SharedPtr<StorageUnitProperties> StorageUnitPropertiesPtr;
 typedef DPL::SharedPtr<StorageProperties> StoragePropertiesPtr;
 typedef DPL::SharedPtr<DisplayProperties> DisplayPropertiesPtr;
 typedef DPL::SharedPtr<WifiNetworkProperties> WifiNetworkPropertiesPtr;