2007-12-11 20:43:17 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services msgservice.h
|
|
|
|
*
|
|
|
|
* Services for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2008 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MESSAGE_SERVICE_HEADER
|
|
|
|
#define MESSAGE_SERVICE_HEADER
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <iostream>
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include "retroshare/rsmsgs.h"
|
2008-02-04 12:55:13 -05:00
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
#include "pqi/pqi.h"
|
|
|
|
#include "pqi/pqiindic.h"
|
2008-06-24 00:22:42 -04:00
|
|
|
|
|
|
|
#include "pqi/pqimonitor.h"
|
|
|
|
#include "pqi/p3cfgmgr.h"
|
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
#include "services/p3service.h"
|
|
|
|
#include "serialiser/rsmsgitems.h"
|
2008-02-04 12:55:13 -05:00
|
|
|
#include "util/rsthreads.h"
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-01-25 02:49:28 -05:00
|
|
|
class p3ConnectMgr;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2010-09-20 18:11:09 -04:00
|
|
|
class p3MsgService: public p3Service, public p3Config, public pqiMonitor
|
2007-12-11 20:43:17 -05:00
|
|
|
{
|
|
|
|
public:
|
2008-01-25 02:49:28 -05:00
|
|
|
p3MsgService(p3ConnectMgr *cm);
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-04 12:55:13 -05:00
|
|
|
/* External Interface */
|
2008-02-04 16:40:34 -05:00
|
|
|
bool MsgsChanged(); /* should update display */
|
|
|
|
bool MsgNotifications(); /* popup - messages */
|
|
|
|
bool getMessageNotifications(std::list<MsgInfoSummary> ¬eList);
|
|
|
|
|
2008-02-04 12:55:13 -05:00
|
|
|
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
2010-08-22 18:12:26 -04:00
|
|
|
bool getMessage(std::string &mid, MessageInfo &msg);
|
2010-05-28 10:42:54 -04:00
|
|
|
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
|
2008-02-04 12:55:13 -05:00
|
|
|
|
2010-08-22 18:12:26 -04:00
|
|
|
bool removeMsgId(std::string &mid);
|
|
|
|
bool markMsgIdRead(std::string &mid, bool bUnreadByUser);
|
2008-02-04 12:55:13 -05:00
|
|
|
|
|
|
|
bool MessageSend(MessageInfo &info);
|
2010-05-25 05:32:14 -04:00
|
|
|
bool MessageToDraft(MessageInfo &info);
|
2010-05-28 10:42:54 -04:00
|
|
|
bool MessageToTrash(std::string mid, bool bTrash);
|
2008-02-04 12:55:13 -05:00
|
|
|
|
2010-08-22 18:12:26 -04:00
|
|
|
bool getMessageTagTypes(MsgTagType& tags);
|
|
|
|
bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color);
|
|
|
|
bool removeMessageTagType(uint32_t tagId);
|
2010-08-19 17:47:26 -04:00
|
|
|
|
2010-08-22 18:12:26 -04:00
|
|
|
bool getMessageTag(std::string &msgId, MsgTagInfo& info);
|
|
|
|
/* set == false && tagId == 0 --> remove all */
|
|
|
|
bool setMessageTag(std::string &msgId, uint32_t tagId, bool set);
|
|
|
|
|
|
|
|
bool resetMessageStandardTagTypes(MsgTagType& tags);
|
2008-02-04 12:55:13 -05:00
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
void loadWelcomeMsg(); /* startup message */
|
|
|
|
|
2008-02-07 11:18:34 -05:00
|
|
|
//std::list<RsMsgItem *> &getMsgList();
|
|
|
|
//std::list<RsMsgItem *> &getMsgOutList();
|
2007-12-11 20:43:17 -05:00
|
|
|
|
|
|
|
int tick();
|
|
|
|
int status();
|
|
|
|
|
2010-09-20 18:11:09 -04:00
|
|
|
/*** Overloaded from p3Config ****/
|
|
|
|
virtual RsSerialiser *setupSerialiser();
|
|
|
|
virtual std::list<RsItem*> saveList(bool& cleanup);
|
|
|
|
virtual bool loadList(std::list<RsItem*> load);
|
|
|
|
virtual void saveDone();
|
|
|
|
/*** Overloaded from p3Config ****/
|
2008-02-07 11:18:34 -05:00
|
|
|
|
|
|
|
/*** Overloaded from pqiMonitor ***/
|
|
|
|
virtual void statusChange(const std::list<pqipeer> &plist);
|
|
|
|
int checkOutgoingMessages();
|
|
|
|
/*** Overloaded from pqiMonitor ***/
|
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
private:
|
|
|
|
|
2008-02-04 16:40:34 -05:00
|
|
|
uint32_t getNewUniqueMsgId();
|
2008-02-04 12:55:13 -05:00
|
|
|
int sendMessage(RsMsgItem *item);
|
2007-12-11 20:43:17 -05:00
|
|
|
int incomingMsgs();
|
|
|
|
|
2008-02-04 12:55:13 -05:00
|
|
|
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
|
|
|
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
|
|
|
|
RsMsgItem *initMIRsMsg(MessageInfo &info, std::string to);
|
|
|
|
|
2010-08-22 18:12:26 -04:00
|
|
|
void initStandardTagTypes();
|
|
|
|
|
2008-02-04 16:40:34 -05:00
|
|
|
p3ConnectMgr *mConnMgr;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-04 12:55:13 -05:00
|
|
|
/* Mutex Required for stuff below */
|
|
|
|
|
2008-02-04 16:40:34 -05:00
|
|
|
RsMutex mMsgMtx;
|
2008-02-04 12:55:13 -05:00
|
|
|
|
2008-02-04 16:40:34 -05:00
|
|
|
/* stored list of messages */
|
|
|
|
std::map<uint32_t, RsMsgItem *> imsg;
|
|
|
|
/* ones that haven't made it out yet! */
|
|
|
|
std::map<uint32_t, RsMsgItem *> msgOutgoing;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-04 16:40:34 -05:00
|
|
|
/* List of notifications to post via Toaster */
|
|
|
|
std::list<MsgInfoSummary> msgNotifications;
|
2008-01-25 02:49:28 -05:00
|
|
|
|
2010-08-19 17:47:26 -04:00
|
|
|
/* maps for tags types and msg tags */
|
|
|
|
|
|
|
|
std::map<uint32_t, RsMsgTagType*> mTags;
|
2010-08-22 18:12:26 -04:00
|
|
|
std::map<uint32_t, RsMsgTags*> mMsgTags;
|
2010-08-19 17:47:26 -04:00
|
|
|
|
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
Indicator msgChanged;
|
2008-02-04 16:40:34 -05:00
|
|
|
uint32_t mMsgUniqueId;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-04 12:55:13 -05:00
|
|
|
std::string config_dir;
|
2007-12-11 20:43:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MESSAGE_SERVICE_HEADER
|