enum OperationType
{
OpUnknown,
- OpMain,
- OpNewMessage,
+ OpDefault,
OpComposeFamily /** For operations Compose, Share, MultiShare and ShareText */
};
+++ /dev/null
-/*
- * Copyright (c) 2009-2015 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.
- *
- */
-
-#ifndef AppControlCommandMain_h_
-#define AppControlCommandMain_h_
-
-#include "AppControlCommand.h"
-
-namespace Msg
-{
- class AppControlCommandMain;
- typedef std::shared_ptr<AppControlCommandMain> AppControlCommandMainRef;
-
- class AppControlCommandMain
- : public AppControlCommand
- {
- public:
- AppControlCommandMain(const std::string &opMsg);
- virtual ~AppControlCommandMain();
-
- private:
- };
-}
-
-#endif /* AppControlCommandMain_h_ */
*
*/
-#ifndef AppControlNewMessage_h_
-#define AppControlNewMessage_h_
+#ifndef AppControlDefault_h_
+#define AppControlDefault_h_
#include "AppControlCommand.h"
#include "MsgTypes.h"
namespace Msg
{
- class AppControlNewMessage;
- typedef std::shared_ptr<AppControlNewMessage> AppControlNewMessageRef;
+ class AppControlDefault;
+ typedef std::shared_ptr<AppControlDefault> AppControlDefaultRef;
- class AppControlNewMessage
+ class AppControlDefault
: public AppControlCommand
{
public:
- enum NewMessageType
+ enum DefaultType
{
UnknownType,
+ MainType, //Type from home screen
ReplyType, //Type for reply message button clicked
- NewMsgType, //Type for view message button clicked
+ ViewType, //Type for view message button clicked
NotificationType //Type from notification panel
};
public:
- AppControlNewMessage(const std::string &opMsg, app_control_h handle);
- virtual ~AppControlNewMessage();
+ AppControlDefault(const std::string &opMsg, app_control_h handle);
+ virtual ~AppControlDefault();
MsgId getMessageId() const;
- NewMessageType getNewMessageType() const;
+ DefaultType getDefaultType() const;
private:
bool isNotificationPanel(app_control_h handle) const;
private:
MsgId m_MsgId;
- NewMessageType m_NewMsgType;
+ DefaultType m_DefaultType;
};
}
-#endif /* AppControlNewMessage_h_ */
+#endif /* AppControlDefault_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-2015 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 "AppControlCommandMain.h"
-
-using namespace Msg;
-
-
-AppControlCommandMain::AppControlCommandMain(const std::string &opMsg)
- : AppControlCommand(opMsg, OpMain)
-{
-}
-
-AppControlCommandMain::~AppControlCommandMain()
-{
-}
-
*
*/
-#include "AppControlNewMessage.h"
+#include "AppControlDefault.h"
using namespace Msg;
const char *keyMsgId = "msgId";
}
-AppControlNewMessage::AppControlNewMessage(const std::string &opMsg, app_control_h handle)
- : AppControlCommand(opMsg, OpNewMessage)
+AppControlDefault::AppControlDefault(const std::string &opMsg, app_control_h handle)
+ : AppControlCommand(opMsg, OpDefault)
, m_MsgId()
- , m_NewMsgType(UnknownType)
+ , m_DefaultType(UnknownType)
{
parse(handle);
}
-AppControlNewMessage::~AppControlNewMessage()
+AppControlDefault::~AppControlDefault()
{
}
-MsgId AppControlNewMessage::getMessageId() const
+MsgId AppControlDefault::getMessageId() const
{
return m_MsgId;
}
-AppControlNewMessage::NewMessageType AppControlNewMessage::getNewMessageType() const
+AppControlDefault::DefaultType AppControlDefault::getDefaultType() const
{
- return m_NewMsgType;
+ return m_DefaultType;
}
-void AppControlNewMessage::parse(app_control_h handle)
+void AppControlDefault::parse(app_control_h handle)
{
char *key = nullptr;
app_control_get_extra_data(handle, keyType, &key);
if(!key)
+ {
+ m_DefaultType = MainType;
return;
+ }
- std::string keyType = key;
+ std::string type = key;
free(key);
- if(keyType == valueReply)
- m_NewMsgType = ReplyType;
- else if(keyType == valueNewMsg)
+ if(type == valueReply)
+ m_DefaultType = ReplyType;
+ else if(type == valueNewMsg)
viewMessage(handle);
else
MSG_LOG("Unknown type!");
free(msgIdStr);
}
-bool AppControlNewMessage::isNotificationPanel(app_control_h handle) const
+bool AppControlDefault::isNotificationPanel(app_control_h handle) const
{
char *keyVal = nullptr;
app_control_get_extra_data(handle, notificationPanel, &keyVal);
- return keyVal != nullptr;
+ if(keyVal)
+ {
+ free(keyVal);
+ return true;
+ }
+ else
+ return false;
}
-void AppControlNewMessage::viewMessage(app_control_h handle)
+void AppControlDefault::viewMessage(app_control_h handle)
{
if(isNotificationPanel(handle))
- m_NewMsgType = NotificationType;
+ m_DefaultType = NotificationType;
else
- m_NewMsgType = NewMsgType;
+ m_DefaultType = ViewType;
}
#include "Logger.h"
#include "AppControlParser.h"
#include "AppControlCommand.h"
-#include "AppControlCommandMain.h"
-#include "AppControlNewMessage.h"
+#include "AppControlDefault.h"
#include "AppControlCompose.h"
#include <app_control.h>
const OperationMap operationMap =
{
- {APP_CONTROL_OPERATION_DEFAULT, AppControlCommand::OpNewMessage},
- {APP_CONTROL_OPERATION_MAIN, AppControlCommand::OpMain},
+ {APP_CONTROL_OPERATION_DEFAULT, AppControlCommand::OpDefault},
+ {APP_CONTROL_OPERATION_MAIN, AppControlCommand::OpDefault},
{APP_CONTROL_OPERATION_COMPOSE, AppControlCommand::OpComposeFamily},
{APP_CONTROL_OPERATION_SHARE, AppControlCommand::OpComposeFamily},
{APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCommand::OpComposeFamily},
switch(opType)
{
- //TODO: Create classes for all operations
- case AppControlCommand::OpMain:
- cmd = std::make_shared<AppControlCommandMain>(opStr);
+ case AppControlCommand::OpDefault:
+ cmd = std::make_shared<AppControlDefault>(opStr, handle);
break;
case AppControlCommand::OpComposeFamily:
cmd = std::make_shared<AppControlCompose>(opStr, handle);
break;
-
- // TODO: impl for other command types
-
default:
case AppControlCommand::OpUnknown:
cmd = std::make_shared<AppControlCommand>(opStr, opType);
#include "NaviFrameView.h"
#include "HwButtonListener.h"
#include "AppControlCommand.h"
-#include "AppControlCommandMain.h"
#include "AppControlCompose.h"
+#include "AppControlDefault.h"
namespace Msg
{
/**
* Executes app control command of default type.
*/
- void execCmd(const AppControlCommandMainRef &cmd);
+ void execCmd(const AppControlDefaultRef &cmd);
/**
* Executes app control command of compose type. This is Compose, Share, MultiShare, ShareText.
private:
void init();
-
+ template<typename T>
+ T *getFrame() const;
bool execCmd(const AppControlCommand &cmd);
virtual void onHwBackButtonClicked();
return true;
}
-void NaviFrameController::execCmd(const AppControlCommandMainRef &cmd)
+void NaviFrameController::execCmd(const AppControlDefaultRef &cmd)
{
if(execCmd(*cmd))
{
- if(isEmpty())
+ AppControlDefault::DefaultType type = cmd->getDefaultType();
+
+ Conversation *conv = getFrame<Conversation>();
+ if(conv)
+ pop();
+
+ MsgThread *thread = getFrame<MsgThread>();
+ if(!thread && type != AppControlDefault::ReplyType)
+ push(*new MsgThread(*this));
+
+ if(type == AppControlDefault::ReplyType || type == AppControlDefault::ViewType)
+ {
+ push(*new Conversation(*this, cmd));
+ }
+ else if(type == AppControlDefault::NotificationType)
{
- MsgThread *threadFrame = new MsgThread(*this);
- push(*threadFrame);
+ if(getMsgEngine().getStorage().getUnreadThreadCount() == 1)
+ push(*new Conversation(*this, cmd));
}
}
}
}
}
+template<typename T>
+T *NaviFrameController::getFrame() const
+{
+ auto items = getItems();
+ for(NaviFrameItem *item : items)
+ {
+ T *frame = dynamic_cast<T*>(item);
+ if(frame)
+ return frame;
+ }
+ return nullptr;
+}
+
void NaviFrameController::onHwBackButtonClicked()
{
pop();
virtual MsgAddressListRef getAddressList(ThreadId id) = 0;
virtual MsgThreadListRef searchThread(const std::string &word) = 0;
virtual void setReadStatus(ThreadId id) = 0;
+ virtual int getUnreadThreadCount() const = 0;
// Message:
virtual MessageSMSListRef getSimMsgList() = 0;
return res;
}
+int MsgStoragePrivate::getUnreadThreadCount() const
+{
+ msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE);
+ msg_struct_list_s peerList;
+
+ int unreadThreadCount = 0;
+ bool oneThread = true;
+
+ msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_READ_STATUS);
+ msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false);
+
+ msg_get_thread_view_list(m_ServiceHandle, sortRule, &peerList);
+ msg_release_struct(&sortRule);
+
+ for(int i = 0; i < peerList.nCount; i++)
+ {
+ int unreadCnt = 0;
+ msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_UNREAD_COUNT_INT, &unreadCnt);
+
+ if(unreadCnt > 0)
+ unreadThreadCount++;
+ }
+
+ return unreadThreadCount;
+}
+
MsgThreadItemRef MsgStoragePrivate::getThread(ThreadId id)
{
MsgThreadItemRef res;
virtual MsgAddressListRef getAddressList(ThreadId id);
virtual MsgThreadListRef searchThread(const std::string &word);
virtual void setReadStatus(ThreadId id);
+ virtual int getUnreadThreadCount() const;
// Message:
virtual MessageSMSListRef getSimMsgList();
#include <string>
#include <memory>
+#include <vector>
#include <Elementary.h>
namespace Msg
{
class NaviFrameView;
+ class NaviFrameItem;
+ typedef std::vector<NaviFrameItem*> NaviFrameItemList;
class NaviFrameItem
: public ViewItem
* Get count of pushed frames.
*/
int getItemsCount() const;
+ /**
+ * Get list of pushed frames.
+ */
+ NaviFrameItemList getItems() const;
/**
* Checks if any frame was pushed.
return res;
}
+NaviFrameItemList NaviFrameView::getItems() const
+{
+ NaviFrameItemList result;
+ Eina_List *list= elm_naviframe_items_get(getEo());
+
+ if(list)
+ {
+ Eina_List *l = nullptr;
+ void *obj = nullptr;
+
+ EINA_LIST_FOREACH(list, l, obj)
+ {
+ NaviFrameItem *item = static_cast<NaviFrameItem*>(elm_object_item_data_get(obj));
+ result.push_back(item);
+ }
+
+ eina_list_free(list);
+ }
+ return result;
+}
+
bool NaviFrameView::isEmpty() const
{
return getItemsCount() <= 0;
void NaviFrameView::push(NaviFrameItem &item, View &content)
{
- push(item, content.getEo());
+ push(item, content);
}
void NaviFrameView::pop()
{
elm_naviframe_item_pop(getEo());
}
-
#include "ConvContactList.h"
#include "ConvList.h"
#include "AppControlCompose.h"
+#include "AppControlDefault.h"
#include "AttachPanel.h"
namespace Msg
, private IAttachPanelListener
{
public:
- Conversation(NaviFrameController &parent, const AppControlComposeRef &cmd = AppControlComposeRef());
+ Conversation(NaviFrameController &parent, const AppControlComposeRef &cmd);
+ Conversation(NaviFrameController &parent, const AppControlDefaultRef &cmd);
Conversation(NaviFrameController &parent, ThreadId threadId);
virtual ~Conversation();
execCmd(cmd);
}
+Conversation::Conversation(NaviFrameController &parent, const AppControlDefaultRef &cmd)
+ : Conversation(parent, false)
+{
+ if(cmd)
+ m_ThreadId = getMsgEngine().getStorage().getMessage(cmd->getMessageId())->getThreadId();
+
+ create();
+
+ if(cmd->getDefaultType() == AppControlDefault::ReplyType)
+ m_pBody->setFocus(true);
+
+}
+
Conversation::Conversation(NaviFrameController &parent,ThreadId threadId)
: Conversation(parent, false)
{
{
// Call before delete all children:
MSG_LOG("");
-
+ saveDraftMsg();
getMsgEngine().getStorage().removeListener(*this);
if(m_pBody)
m_pBody->setListener(nullptr);
return;
}
- saveDraftMsg();
getParent().pop();
}
#include "CallbackAssist.h"
#include "Logger.h"
#include "AppControlParser.h"
-#include "AppControlCommandMain.h"
+#include "AppControlDefault.h"
#include "AppControlCompose.h"
#include "PathUtils.h"
#include "Config.h"
switch(cmd->getOperationType())
{
- case AppControlCommand::OpMain:
+ case AppControlCommand::OpDefault:
if(m_pRootController)
- m_pRootController->execCmd(std::static_pointer_cast<AppControlCommandMain>(cmd));
+ m_pRootController->execCmd(std::static_pointer_cast<AppControlDefault>(cmd));
break;
case AppControlCommand::OpComposeFamily:
if(m_pRootController)
void MsgThread::composeNewMessage()
{
- Conversation *frame = new Conversation(getParent());
+ Conversation *frame = new Conversation(getParent(), AppControlComposeRef());
getParent().push(*frame);
}