Added read/unread state to channel service (copied from forum service).

Added new and missing tests of the RsItems.
Added new notifier on channel changes.
Reworked fill of channels in ChannelFeed. Now the channel tree is updated and not refilled.
Show unread message count in channels tree.
Fixed memory leak in context menu.
Show a new tray icon and action icon in MainWindow, when new channel messages are available.

Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3626 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-10-07 00:17:42 +00:00
parent df20d69b29
commit fc0ff38206
22 changed files with 1181 additions and 653 deletions

View file

@ -34,6 +34,10 @@
#include "rstypes.h"
#include "rsdistrib.h" /* For FLAGS */
#define CHANNEL_MSG_STATUS_MASK 0x000f
#define CHANNEL_MSG_STATUS_READ 0x0001
#define CHANNEL_MSG_STATUS_UNREAD_BY_USER 0x0002
//! Stores information for a give channel id
/*!
* Stores all information for a given channel id
@ -167,6 +171,31 @@ virtual bool getChannelMsgList(std::string cId, std::list<ChannelMsgSummary> &ms
*/
virtual bool getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &msg) = 0;
/*!
* set message status
* @param cId channel id
* @param mId message id
* @param status status to set
* @param statusMask bitmask to modify
*/
virtual bool setMessageStatus(const std::string& cId,const std::string& mId, const uint32_t status, const uint32_t statusMask) = 0;
/*!
* set message status
* @param cId channel id
* @param mId message id
* @param status status
*/
virtual bool getMessageStatus(const std::string& cId, const std::string& mId, uint32_t& status) = 0;
/*!
* count the new and unread messages
* @param cId channel id
* @param newCount count of new messages
* @param unreadCount count of unread messages
*/
virtual bool getMessageCount(const std::string cId, unsigned int &newCount, unsigned int &unreadCount) = 0;
/*!
* send message contain in message info to the id indicated within it (make sure you set the channel id of the message info)
* @param info message to be sent

View file

@ -198,6 +198,7 @@ class NotifyBase
virtual void notifyPeerStatusChanged(const std::string& /* peer_id */, uint32_t /* status */) {}
/* one or more peers has changed the states */
virtual void notifyPeerStatusChangedSummary() {}
virtual void notifyChannelMsgReadSatusChanged(const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
virtual std::string askForPassword(const std::string& /* key_details */ ,bool /* prev_is_bad */ ) { return "" ;}
};
@ -217,6 +218,7 @@ const int NOTIFY_LIST_PUBLIC_CHAT = 13;
const int NOTIFY_LIST_PRIVATE_INCOMING_CHAT = 14;
const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15;
const int NOTIFY_LIST_GROUPLIST = 16;
const int NOTIFY_LIST_CHANNELLIST_LOCKED = 17; // use connect with Qt::QueuedConnection
const int NOTIFY_TYPE_SAME = 0x01;
const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */

View file

@ -74,6 +74,45 @@ std::ostream &RsChannelMsg::print(std::ostream &out, uint16_t indent)
return out;
}
void RsChannelReadStatus::clear()
{
RsDistribChildConfig::clear();
channelId.clear();
msgReadStatus.clear();
return;
}
std::ostream& RsChannelReadStatus::print(std::ostream &out, uint16_t indent = 0)
{
printRsItemBase(out, "RsChannelMsg", indent);
uint16_t int_Indent = indent + 2;
RsDistribChildConfig::print(out, int_Indent);
printIndent(out, int_Indent);
out << "ChannelId: " << channelId << std::endl;
std::map<std::string, uint32_t>::iterator mit = msgReadStatus.begin();
for(; mit != msgReadStatus.end(); mit++)
{
printIndent(out, int_Indent);
out << "msgId : " << mit->first << std::endl;
printIndent(out, int_Indent);
out << " status : " << mit->second << std::endl;
}
printRsItemEnd(out, "RsChannelMsg", indent);
return out;
}
/*************************************************************************/
/*************************************************************************/
@ -204,19 +243,207 @@ RsChannelMsg *RsChannelSerialiser::deserialiseMsg(void *data, uint32_t *pktsize)
}
uint32_t RsChannelSerialiser::sizeReadStatus(RsChannelReadStatus *item)
{
uint32_t s = 8; /* header */
/* RsDistribChildConfig stuff */
s += 4; /* save_type */
/* RsChannelReadStatus stuff */
s += GetTlvStringSize(item->channelId);
std::map<std::string, uint32_t>::iterator mit = item->msgReadStatus.begin();
for(; mit != item->msgReadStatus.end(); mit++)
{
s += GetTlvStringSize(mit->first); /* key */
s += 4; /* value */
}
return s;
}
/* serialise the data to the buffer */
bool RsChannelSerialiser::serialiseReadStatus(RsChannelReadStatus *item, void *data, uint32_t *pktsize)
{
uint32_t tlvsize = sizeReadStatus(item);
uint32_t offset = 0;
if (*pktsize < tlvsize)
return false; /* not enough space */
*pktsize = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
std::cerr << "RsChannelSerialiser::serialiseReadStatus() Header: " << ok << std::endl;
std::cerr << "RsChannelSerialiser::serialiseReadStatus() Size: " << tlvsize << std::endl;
/* skip the header */
offset += 8;
/* RsDistribMsg first */
ok &= setRawUInt32(data, tlvsize, &offset, item->save_type);
std::cerr << "RsChannelSerialiser::serialiseReadStatus() save_type: " << ok << std::endl;
/* RsChannelMsg */
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GROUPID, item->channelId);
std::cerr << "RsChannelSerialiser::serialiseReadStatus() channelId: " << ok << std::endl;
std::map<std::string, uint32_t>::iterator mit = item->msgReadStatus.begin();
for(; mit != item->msgReadStatus.end(); mit++)
{
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSGID, mit->first); /* key */
ok &= setRawUInt32(data, tlvsize, &offset, mit->second); /* value */
}
std::cerr << "RsChannelSerialiser::serialiseReadStatus() msgReadStatus: " << ok << std::endl;
if (offset != tlvsize)
{
ok = false;
std::cerr << "RsChannelSerialiser::serialiseReadStatus() Size Error! " << std::endl;
}
return ok;
}
RsChannelReadStatus *RsChannelSerialiser::deserialiseReadStatus(void *data, uint32_t *pktsize)
{
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_TYPE_CHANNEL != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_CHANNEL_READ_STATUS != getRsItemSubType(rstype)))
{
return NULL; /* wrong type */
}
if (*pktsize < rssize) /* check size */
return NULL; /* not enough data */
/* set the packet length */
*pktsize = rssize;
bool ok = true;
/* ready to load */
RsChannelReadStatus *item = new RsChannelReadStatus();
item->clear();
/* skip the header */
offset += 8;
/* RsDistribMsg first */
ok &= getRawUInt32(data, rssize, &offset, &(item->save_type));
/* RschannelMsg */
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GROUPID, item->channelId);
std::string key;
uint32_t value;
while(offset != rssize)
{
key.clear();
value = 0;
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSGID, key); /* key */
/* incomplete key value pair? then fail*/
if(offset == rssize)
{
delete item;
return NULL;
}
ok &= getRawUInt32(data, rssize, &offset, &value); /* value */
item->msgReadStatus.insert(std::pair<std::string, uint32_t>(key, value));
}
if (!ok)
{
delete item;
return NULL;
}
return item;
}
/************************************************************/
uint32_t RsChannelSerialiser::size(RsItem *item)
{
return sizeMsg((RsChannelMsg *) item);
RsChannelMsg* dcm;
RsChannelReadStatus* drs;
if( NULL != ( dcm = dynamic_cast<RsChannelMsg*>(item)))
{
return sizeMsg(dcm);
}
else if(NULL != (drs = dynamic_cast<RsChannelReadStatus* >(item)))
{
return sizeReadStatus(drs);
}
return false;
}
bool RsChannelSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
{
return serialiseMsg((RsChannelMsg *) item, data, pktsize);
RsChannelMsg* dcm;
RsChannelReadStatus* drs;
if( NULL != ( dcm = dynamic_cast<RsChannelMsg*>(item)))
{
return serialiseMsg(dcm, data, pktsize);
}
else if(NULL != (drs = dynamic_cast<RsChannelReadStatus* >(item)))
{
return serialiseReadStatus(drs, data, pktsize);
}
return false;
}
RsItem *RsChannelSerialiser::deserialise(void *data, uint32_t *pktsize)
{
/* get the type and size */
uint32_t rstype = getRsItemId(data);
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_TYPE_CHANNEL != getRsItemService(rstype)))
{
return NULL; /* wrong type */
}
switch(getRsItemSubType(rstype))
{
case RS_PKT_SUBTYPE_CHANNEL_MSG:
return deserialiseMsg(data, pktsize);
case RS_PKT_SUBTYPE_CHANNEL_READ_STATUS:
return deserialiseReadStatus(data, pktsize);
default:
return NULL;
}
return NULL;
}

View file

@ -36,6 +36,7 @@
#include "serialiser/rsdistribitems.h"
const uint8_t RS_PKT_SUBTYPE_CHANNEL_MSG = 0x01;
const uint8_t RS_PKT_SUBTYPE_CHANNEL_READ_STATUS = 0x02;
/**************************************************************************/
@ -63,6 +64,29 @@ virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
};
/*!
* This is used to keep track of whether a message has been read
* by client
*/
class RsChannelReadStatus : public RsDistribChildConfig
{
public:
RsChannelReadStatus()
: RsDistribChildConfig(RS_SERVICE_TYPE_CHANNEL, RS_PKT_SUBTYPE_CHANNEL_READ_STATUS)
{ return; }
virtual ~RsChannelReadStatus() {return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent);
std::string channelId;
/// a map which contains the read for messages within a forum
std::map<std::string, uint32_t> msgReadStatus;
};
class RsChannelSerialiser: public RsSerialType
{
public:
@ -83,6 +107,10 @@ virtual uint32_t sizeMsg(RsChannelMsg *);
virtual bool serialiseMsg(RsChannelMsg *item, void *data, uint32_t *size);
virtual RsChannelMsg *deserialiseMsg(void *data, uint32_t *size);
virtual uint32_t sizeReadStatus(RsChannelReadStatus* );
virtual bool serialiseReadStatus(RsChannelReadStatus* item, void* data, uint32_t *size);
virtual RsChannelReadStatus *deserialiseReadStatus(void* data, uint32_t *size);
};
/**************************************************************************/

View file

@ -25,6 +25,7 @@
#include "services/p3channels.h"
#include "util/rsdir.h"
#include "retroshare/rsiface.h"
std::ostream &operator<<(std::ostream &out, const ChannelInfo &info)
{
@ -182,14 +183,14 @@ bool p3Channels::getChannelMsgList(std::string cId, std::list<ChannelMsgSummary>
return true;
}
bool p3Channels::getChannelMessage(std::string fId, std::string mId, ChannelMsgInfo &info)
bool p3Channels::getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &info)
{
std::list<std::string> msgIds;
std::list<std::string>::iterator it;
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
RsDistribMsg *msg = locked_getGroupMsg(fId, mId);
RsDistribMsg *msg = locked_getGroupMsg(cId, mId);
RsChannelMsg *cmsg = dynamic_cast<RsChannelMsg *>(msg);
if (!cmsg)
return false;
@ -285,9 +286,181 @@ bool p3Channels::ChannelMessageSend(ChannelMsgInfo &info)
std::string msgId = publishMsg(cmsg, toSign);
if (msgId.empty()) {
return false;
}
return setMessageStatus(info.channelId, msgId, CHANNEL_MSG_STATUS_READ, CHANNEL_MSG_STATUS_MASK);
}
bool p3Channels::setMessageStatus(const std::string& cId,const std::string& mId,const uint32_t status, const uint32_t statusMask)
{
bool changed = false;
uint32_t newStatus = 0;
{
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
std::list<RsChannelReadStatus *>::iterator lit = mReadStatus.begin();
for(; lit != mReadStatus.end(); lit++)
{
if((*lit)->channelId == cId)
{
RsChannelReadStatus* rsi = *lit;
uint32_t oldStatus = rsi->msgReadStatus[mId];
rsi->msgReadStatus[mId] &= ~statusMask;
rsi->msgReadStatus[mId] |= (status & statusMask);
newStatus = rsi->msgReadStatus[mId];
if (oldStatus != newStatus) {
changed = true;
}
break;
}
}
// if channel id does not exist create one
if(lit == mReadStatus.end())
{
RsChannelReadStatus* rsi = new RsChannelReadStatus();
rsi->channelId = cId;
rsi->msgReadStatus[mId] = status & statusMask;
mReadStatus.push_back(rsi);
saveList.push_back(rsi);
newStatus = rsi->msgReadStatus[mId];
changed = true;
}
if (changed) {
IndicateConfigChanged();
}
} /******* UNLOCKED ********/
if (changed) {
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHANNELLIST_LOCKED, NOTIFY_TYPE_MOD);
rsicontrol->getNotify().notifyChannelMsgReadSatusChanged(cId, mId, newStatus);
}
return true;
}
bool p3Channels::getMessageStatus(const std::string& cId, const std::string& mId, uint32_t& status)
{
status = 0;
RsStackMutex stack(distribMtx);
std::list<RsChannelReadStatus *>::iterator lit = mReadStatus.begin();
for(; lit != mReadStatus.end(); lit++)
{
if((*lit)->channelId == cId)
{
break;
}
}
if(lit == mReadStatus.end())
{
return false;
}
std::map<std::string, uint32_t >::iterator mit = (*lit)->msgReadStatus.find(mId);
if(mit != (*lit)->msgReadStatus.end())
{
status = mit->second;
return true;
}
return false;
}
bool p3Channels::getMessageCount(const std::string cId, unsigned int &newCount, unsigned int &unreadCount)
{
newCount = 0;
unreadCount = 0;
std::list<std::string> grpIds;
if (cId.empty()) {
// count all messages of all subscribed channels
getAllGroupList(grpIds);
} else {
// count all messages of one channels
grpIds.push_back(cId);
}
std::list<std::string>::iterator git;
for (git = grpIds.begin(); git != grpIds.end(); git++) {
std::string cId = *git;
uint32_t grpFlags;
{
// only flag is needed
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
GroupInfo *gi = locked_getGroupInfo(cId);
if (gi == NULL) {
return false;
}
grpFlags = gi->flags;
} /******* UNLOCKED ********/
if (grpFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED)) {
std::list<std::string> msgIds;
if (getAllMsgList(cId, msgIds)) {
std::list<std::string>::iterator mit;
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
std::list<RsChannelReadStatus *>::iterator lit;
for(lit = mReadStatus.begin(); lit != mReadStatus.end(); lit++) {
if ((*lit)->channelId == cId) {
break;
}
}
if (lit == mReadStatus.end()) {
// no status available -> all messages are new
newCount += msgIds.size();
unreadCount += msgIds.size();
continue;
}
for (mit = msgIds.begin(); mit != msgIds.end(); mit++) {
std::map<std::string, uint32_t >::iterator rit = (*lit)->msgReadStatus.find(*mit);
if (rit == (*lit)->msgReadStatus.end()) {
// no status available -> message is new
newCount++;
unreadCount++;
continue;
}
if (rit->second & CHANNEL_MSG_STATUS_READ) {
// message is not new
if (rit->second & CHANNEL_MSG_STATUS_UNREAD_BY_USER) {
// message is unread
unreadCount++;
}
} else {
newCount++;
unreadCount++;
}
}
} /******* UNLOCKED ********/
}
}
return true;
}
bool p3Channels::channelExtraFileHash(std::string path, std::string chId, FileInfo& fInfo){
@ -636,7 +809,6 @@ bool p3Channels::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::stri
return locked_eventDuplicateMsg(grp, msg, id);
}
void p3Channels::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
{
std::string grpId = grp.grpId;
@ -655,12 +827,14 @@ void p3Channels::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
std::cerr << "p3Channels::locked_notifyGroupChanged() NEW UPDATE" << std::endl;
#endif
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAN_NEW, grpId, msgId, nullId);
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHANNELLIST_LOCKED, NOTIFY_TYPE_ADD);
break;
case GRP_UPDATE:
#ifdef CHANNEL_DEBUG
std::cerr << "p3Channels::locked_notifyGroupChanged() UPDATE" << std::endl;
#endif
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAN_UPDATE, grpId, msgId, nullId);
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHANNELLIST_LOCKED, NOTIFY_TYPE_MOD);
break;
case GRP_LOAD_KEY:
#ifdef CHANNEL_DEBUG
@ -671,6 +845,7 @@ void p3Channels::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
#ifdef CHANNEL_DEBUG
std::cerr << "p3Channels::locked_notifyGroupChanged() NEW MSG" << std::endl;
#endif
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHANNELLIST_LOCKED, NOTIFY_TYPE_ADD);
break;
case GRP_SUBSCRIBED:
#ifdef CHANNEL_DEBUG
@ -690,11 +865,13 @@ void p3Channels::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
/* check if downloads need to be started? */
}
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHANNELLIST_LOCKED, NOTIFY_TYPE_ADD);
break;
case GRP_UNSUBSCRIBED:
#ifdef CHANNEL_DEBUG
std::cerr << "p3Channels::locked_notifyGroupChanged() UNSUBSCRIBED" << std::endl;
#endif
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHANNELLIST_LOCKED, NOTIFY_TYPE_DEL);
/* won't stop downloads... */
@ -778,6 +955,24 @@ void p3Channels::cleanUpOldFiles(){
//TODO: if you want to config saving and loading for channel distrib service implement this method further
bool p3Channels::childLoadList(std::list<RsItem* >& configSaves)
{
RsChannelReadStatus* drs = NULL;
std::list<RsItem* >::iterator it;
for(it = configSaves.begin(); it != configSaves.end(); it++)
{
if(NULL != (drs = dynamic_cast<RsChannelReadStatus* >(*it)))
{
mReadStatus.push_back(drs);
saveList.push_back(drs);
}
else
{
std::cerr << "p3Channels::childLoadList(): Configs items loaded were incorrect!"
<< std::endl;
return false;
}
}
return true;
}

View file

@ -67,6 +67,10 @@ virtual bool getChannelMsgList(std::string cId, std::list<ChannelMsgSummary> &ms
virtual bool getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &msg);
virtual bool ChannelMessageSend(ChannelMsgInfo &info);
virtual bool setMessageStatus(const std::string& cId, const std::string& mId, const uint32_t status, const uint32_t statusMask);
virtual bool getMessageStatus(const std::string& cId, const std::string& mId, uint32_t& status);
virtual bool getMessageCount(const std::string cId, unsigned int &newCount, unsigned int &unreadCount);
virtual bool channelSubscribe(std::string cId, bool subscribe);
virtual bool channelExtraFileHash(std::string path, std::string chId, FileInfo& fInfo);
@ -106,6 +110,7 @@ bool cpyMsgFileToChFldr(std::string path, std::string fname, std::string chId, b
std::string mChannelsDir;
std::list<RsItem *> saveList;
std::list<RsChannelReadStatus *> mReadStatus;
};

View file

@ -564,9 +564,11 @@ void p3Forums::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_FORUMLIST_LOCKED, NOTIFY_TYPE_ADD);
break;
case GRP_SUBSCRIBED:
case GRP_UNSUBSCRIBED:
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_FORUMLIST_LOCKED, NOTIFY_TYPE_ADD);
break;
case GRP_UNSUBSCRIBED:
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_FORUMLIST_LOCKED, NOTIFY_TYPE_DEL);
break;
}
return p3GroupDistrib::locked_notifyGroupChanged(grp, flags);
}

View file

@ -276,6 +276,51 @@ bool operator==(const RsForumReadStatus& frs1, const RsForumReadStatus& frs2)
RsSerialType* init_item(RsChannelReadStatus& fRdStatus)
{
randString(SHORT_STR, fRdStatus.channelId);
fRdStatus.save_type = rand()%42;
std::map<std::string, uint32_t>::iterator mit = fRdStatus.msgReadStatus.begin();
std::string id;
uint32_t status = 0;
int numMaps = rand()%12;
for(int i = 0; i < numMaps; i++)
{
randString(SHORT_STR, id);
status = rand()%23;
fRdStatus.msgReadStatus.insert(std::pair<std::string, uint32_t>(id, status));
}
return new RsChannelSerialiser();
}
bool operator==(const RsChannelReadStatus& frs1, const RsChannelReadStatus& frs2)
{
if(frs1.channelId != frs2.channelId) return false;
if(frs1.save_type != frs2.save_type) return false;
if(frs1.msgReadStatus.size() != frs2.msgReadStatus.size()) return false;
std::map<std::string, uint32_t>::const_iterator mit
= frs1.msgReadStatus.begin();
for(;mit != frs1.msgReadStatus.end(); mit++)
{
if(mit->second != frs2.msgReadStatus.find(mit->first)->second) return false;
}
return true;
}
bool operator==(const RsBlogMsg& bMsg1,const RsBlogMsg& bMsg2)
{
@ -307,6 +352,7 @@ int main(){
test_RsItem<RsDistribGrpKey>(); REPORT("Serialise/Deserialise RsDistribGrpKey");
test_RsItem<RsDistribSignedMsg>(); REPORT("Serialise/Deserialise RsDistribSignedMsg");
test_RsItem<RsChannelMsg>(); REPORT("Serialise/Deserialise RsChannelMsg");
test_RsItem<RsChannelReadStatus>(); REPORT("Serialise/Deserialise RsChannelReadStatus");
test_RsItem<RsForumMsg>(); REPORT("Serialise/Deserialise RsForumMsg");
test_RsItem<RsForumReadStatus>(); REPORT("Serialise/Deserialise RsForumReadStatus");
test_RsItem<RsBlogMsg>(); REPORT("Serialise/Deserialise RsBlogMsg");

View file

@ -42,6 +42,18 @@ RsSerialType* init_item(RsChatMsgItem& cmi)
return new RsChatSerialiser();
}
RsSerialType* init_item(RsPrivateChatMsgConfigItem& pcmi)
{
randString(SHORT_STR, pcmi.configPeerId);
pcmi.chatFlags = rand()%34;
pcmi.configFlags = rand()%21;
pcmi.sendTime = rand()%422224;
randString(LARGE_STR, pcmi.message);
pcmi.recvTime = rand()%344443;
return new RsChatSerialiser();
}
RsSerialType* init_item(RsChatStatusItem& csi)
{
@ -123,6 +135,19 @@ bool operator ==(const RsChatMsgItem& cmiLeft,const RsChatMsgItem& cmiRight)
return true;
}
bool operator ==(const RsPrivateChatMsgConfigItem& pcmiLeft,const RsPrivateChatMsgConfigItem& pcmiRight)
{
if(pcmiLeft.configPeerId != pcmiRight.configPeerId) return false;
if(pcmiLeft.chatFlags != pcmiRight.chatFlags) return false;
if(pcmiLeft.configFlags != pcmiRight.configFlags) return false;
if(pcmiLeft.message != pcmiRight.message) return false;
if(pcmiLeft.sendTime != pcmiRight.sendTime) return false;
if(pcmiLeft.recvTime != pcmiRight.recvTime) return false;
return true;
}
bool operator ==(const RsChatStatusItem& csiLeft, const RsChatStatusItem& csiRight)
{
if(csiLeft.flags != csiRight.flags) return false;
@ -201,6 +226,7 @@ bool operator ==(const RsMsgSrcId& msLeft, const RsMsgSrcId& msRight)
int main()
{
test_RsItem<RsChatMsgItem >(); REPORT("Serialise/Deserialise RsChatMsgItem");
test_RsItem<RsChatMsgItem >(); REPORT("Serialise/Deserialise RsPrivateChatMsgConfigItem");
test_RsItem<RsChatStatusItem >(); REPORT("Serialise/Deserialise RsChatStatusItem");
test_RsItem<RsChatAvatarItem >(); REPORT("Serialise/Deserialise RsChatAvatarItem");
test_RsItem<RsMsgItem >(); REPORT("Serialise/Deserialise RsMsgItem");

View file

@ -26,22 +26,29 @@
#include <iostream>
#include <algorithm>
#include <retroshare/rschannels.h>
#include "ChannelFeed.h"
#include "gui/feeds/ChanMsgItem.h"
#include "feeds/ChanMsgItem.h"
#include "gui/channels/CreateChannel.h"
#include "gui/channels/ChannelDetails.h"
#include "gui/channels/CreateChannelMsg.h"
#include "gui/channels/EditChanDetails.h"
#include "gui/channels/ShareKey.h"
#include "channels/CreateChannel.h"
#include "channels/ChannelDetails.h"
#include "channels/CreateChannelMsg.h"
#include "channels/EditChanDetails.h"
#include "channels/ShareKey.h"
#include "notifyqt.h"
#include "gui/ChanGroupDelegate.h"
#include "ChanGroupDelegate.h"
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
#define COLUMN_NAME 0
#define COLUMN_POPULARITY 1
#define COLUMN_COUNT 2
#define COLUMN_DATA COLUMN_NAME
#define ROLE_ID Qt::UserRole
#define ROLE_CHANNEL_TITLE Qt::UserRole + 1
/****
* #define CHAN_DEBUG
***/
@ -57,18 +64,18 @@ ChannelFeed::ChannelFeed(QWidget *parent)
connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
connect(setAllAsReadButton, SIGNAL(clicked()), this, SLOT(setAllAsReadClicked()));
connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
/*************** Setup Left Hand Side (List of Channels) ****************/
connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectChannel(const QModelIndex &)));
connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &)));
connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( channelListCustomPopupMenu( QPoint ) ) );
mChannelId = "";
model = new QStandardItemModel(0, 3, this);
model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
model->setHeaderData(1, Qt::Horizontal, tr("Popularity"), Qt::DisplayRole);
model->setHeaderData(2, Qt::Horizontal, tr("ID"), Qt::DisplayRole);
mChannelId.clear();
model = new QStandardItemModel(0, 2, this);
model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
model->setHeaderData(COLUMN_POPULARITY, Qt::Horizontal, tr("Popularity"), Qt::DisplayRole);
treeView->setModel(model);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
@ -76,16 +83,15 @@ ChannelFeed::ChannelFeed(QWidget *parent)
treeView->setItemDelegate(new ChanGroupDelegate());
treeView->setRootIsDecorated(true);
connect(treeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(selectChannel(QModelIndex)));
// hide header and id column
treeView->setHeaderHidden(true);
treeView->hideColumn(2);
/* Set header resize modes and initial section sizes TreeView*/
QHeaderView * _header = treeView->header () ;
_header->setResizeMode ( 1, QHeaderView::Custom);
_header->resizeSection ( 0, 190 );
_header->resizeSection ( 1, 22 );
_header->resizeSection ( 2, 22 );
_header->setResizeMode ( COLUMN_POPULARITY, QHeaderView::Custom);
_header->resizeSection ( COLUMN_NAME, 190 );
// set ChannelList Font
itemFont = QFont("ARIAL", 10);
@ -129,64 +135,56 @@ ChannelFeed::ChannelFeed(QWidget *parent)
channelpushButton->setMenu(channelmenu);
updateChannelMsgs();
}
void ChannelFeed::channelListCustomPopupMenu( QPoint point )
{
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci))
{
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
return;
}
QMenu contextMnu(this);
postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), this );
QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );
subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), this );
QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );
unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), this );
QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu);
connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );
channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), this );
QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );
restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), this );
QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );
editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), this);
QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );
shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), this);
QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_ADMIN))
{
if ((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_ADMIN)) {
contextMnu.addAction( postchannelAct );
contextMnu.addSeparator();
contextMnu.addAction( editChannelDetailAct);
contextMnu.addAction( shareKeyAct );
contextMnu.addAction( channeldetailsAct );
}
else if (ci.channelFlags & RS_DISTRIB_PUBLISH)
{
else if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
contextMnu.addAction( postchannelAct );
contextMnu.addSeparator();
contextMnu.addAction( channeldetailsAct );
contextMnu.addAction( shareKeyAct );
}
else if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
{
} else if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
contextMnu.addAction( unsubscribechannelAct );
contextMnu.addSeparator();
contextMnu.addAction( channeldetailsAct );
contextMnu.addAction( restoreKeysAct );
}
else
{
} else {
contextMnu.addAction( subscribechannelAct );
contextMnu.addSeparator();
contextMnu.addAction( channeldetailsAct );
@ -212,92 +210,82 @@ void ChannelFeed::channelSelection()
updateChannelMsgs();
}
/*************************************************************************************/
/*************************************************************************************/
/*************************************************************************************/
void ChannelFeed::deleteFeedItem(QWidget *item, uint32_t type)
{
return;
}
void ChannelFeed::openChat(std::string peerId)
{
return;
}
void ChannelFeed::editChannelDetail(){
EditChanDetails editUi(this, 0, mChannelId);
editUi.exec();
return;
}
void ChannelFeed::shareKey()
{
ShareKey shareUi(this, 0, mChannelId);
shareUi.exec();
return;
}
void ChannelFeed::createMsg()
{
if (mChannelId == "")
{
if (mChannelId.empty()) {
return;
}
CreateChannelMsg *msgDialog = new CreateChannelMsg(mChannelId);
msgDialog->show();
/* window will destroy itself! */
}
void ChannelFeed::selectChannel( std::string cId)
void ChannelFeed::restoreChannelKeys()
{
mChannelId = cId;
updateChannelMsgs();
}
void ChannelFeed::restoreChannelKeys(){
rsChannels->channelRestoreKeys(mChannelId);
}
void ChannelFeed::selectChannel(const QModelIndex &index)
void ChannelFeed::selectChannel(QModelIndex index)
{
int row = index.row();
int col = index.column();
if (col != 2) {
QModelIndex sibling = index.sibling(row, 2);
if (sibling.isValid())
mChannelId = sibling.data().toString().toStdString();
} else
mChannelId = index.data().toString().toStdString();
QStandardItem *itemData = NULL;
if (index.isValid()) {
QStandardItem *item = model->itemFromIndex(index);
if (item && item->parent() != NULL) {
itemData = item->parent()->child(item->row(), COLUMN_DATA);
}
}
if (itemData) {
mChannelId = itemData->data(ROLE_ID).toString().toStdString();
} else {
mChannelId.clear();
}
updateChannelMsgs();
}
void ChannelFeed::updateDisplay()
{
if (!rsChannels) {
return;
}
std::list<std::string> chanIds;
std::list<std::string>::iterator it;
if (!rsChannels)
return;
if (rsChannels->channelsChanged(chanIds))
{
/* update Forums List */
if (rsChannels->channelsChanged(chanIds)) {
/* update channel list */
updateChannelList();
it = std::find(chanIds.begin(), chanIds.end(), mChannelId);
if (it != chanIds.end())
{
if (it != chanIds.end()) {
updateChannelMsgs();
}
}
@ -305,370 +293,211 @@ void ChannelFeed::updateDisplay()
void ChannelFeed::updateChannelList()
{
if (!rsChannels) {
return;
}
std::list<ChannelInfo> channelList;
std::list<ChannelInfo>::iterator it;
if (!rsChannels)
{
return;
}
rsChannels->getChannelList(channelList);
/* get the ids for our lists */
std::list<std::string> adminIds;
std::list<std::string> subIds;
std::list<std::string> popIds;
std::list<std::string> otherIds;
std::multimap<uint32_t, std::string> popMap;
std::list<ChannelInfo> adminList;
std::list<ChannelInfo> subList;
std::list<ChannelInfo> popList;
std::list<ChannelInfo> otherList;
std::multimap<uint32_t, ChannelInfo> popMap;
for(it = channelList.begin(); it != channelList.end(); it++)
{
for(it = channelList.begin(); it != channelList.end(); it++) {
/* sort it into Publish (Own), Subscribed, Popular and Other */
uint32_t flags = it->channelFlags;
if (flags & RS_DISTRIB_ADMIN)
{
adminIds.push_back(it->channelId);
}
else if (flags & RS_DISTRIB_SUBSCRIBED)
{
subIds.push_back(it->channelId);
}
else
{
if (flags & RS_DISTRIB_ADMIN) {
adminList.push_back(*it);
} else if (flags & RS_DISTRIB_SUBSCRIBED) {
subList.push_back(*it);
} else {
/* rate the others by popularity */
popMap.insert(std::make_pair(it->pop, it->channelId));
popMap.insert(std::make_pair(it->pop, *it));
}
}
/* iterate backwards through popMap - take the top 5 or 10% of list */
uint32_t popCount = 5;
if (popCount < popMap.size() / 10)
{
if (popCount < popMap.size() / 10) {
popCount = popMap.size() / 10;
}
uint32_t i = 0;
std::multimap<uint32_t, std::string>::reverse_iterator rit;
for(rit = popMap.rbegin(); rit != popMap.rend(); rit++)
{
std::multimap<uint32_t, ChannelInfo>::reverse_iterator rit;
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
if (i < popCount) {
popIds.push_back(rit->second);
popList.push_back(rit->second);
i++;
} else {
otherIds.push_back(rit->second);
otherList.push_back(rit->second);
}
}
/* now we have our lists ---> update entries */
updateChannelListOwn(adminIds);
updateChannelListSub(subIds);
updateChannelListPop(popIds);
updateChannelListOther(otherIds);
fillChannelList(OWN, adminList);
fillChannelList(SUBSCRIBED, subList);
fillChannelList(POPULAR, popList);
fillChannelList(OTHER, otherList);
updateMessageSummaryList("");
}
void ChannelFeed::updateChannelListOwn(std::list<std::string> &ids)
void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos)
{
std::list<std::string>::iterator iit;
std::list<ChannelInfo>::iterator iit;
/* remove rows with groups before adding new ones */
model->item(OWN)->removeRows(0, model->item(OWN)->rowCount());
QStandardItem *groupItem = model->item(channelItem);
if (groupItem == NULL) {
return;
}
for (iit = ids.begin(); iit != ids.end(); iit ++) {
/* iterate all channels */
for (iit = channelInfos.begin(); iit != channelInfos.end(); iit++) {
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << std::endl;
std::cerr << "ChannelFeed::fillChannelList(): " << channelItem << " - " << iit->channelId << std::endl;
#endif
QStandardItem *ownGroup = model->item(OWN);
QList<QStandardItem *> channel;
ChannelInfo &ci = *iit;
QString channelId = QString::fromStdString(ci.channelId);
/* search exisiting channel item */
int row;
int rowCount = groupItem->rowCount();
for (row = 0; row < rowCount; row++) {
if (groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString() == channelId) {
/* found channel */
break;
}
}
QStandardItem *chNameItem = new QStandardItem();
QStandardItem *chPopItem = new QStandardItem();
QStandardItem *chIdItem = new QStandardItem();
if (row < rowCount) {
chNameItem = groupItem->child(row, COLUMN_NAME);
chPopItem = groupItem->child(row, COLUMN_POPULARITY);
} else {
QList<QStandardItem*> channel;
chNameItem = new QStandardItem();
chPopItem = new QStandardItem();
chNameItem->setSizeHint(QSize(22, 22));
ChannelInfo ci;
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
//chPopItem->setData(QVariant(QString::number(ci.pop)), Qt::DisplayRole);
chIdItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
channel.append(chNameItem);
channel.append(chPopItem);
groupItem->appendRow(channel);
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(channelId, ROLE_ID);
}
chNameItem->setText(QString::fromStdWString(ci.channelName));
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QString::fromStdWString(ci.channelName), ROLE_CHANNEL_TITLE);
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3").arg(QString::number(ci.pop)).arg(9999).arg(9999));
if(ci.pngImageLen != 0){
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
chNameItem->setData(QIcon(chanImage), Qt::DecorationRole);
}else{
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
chNameItem->setData(QIcon(defaulImage), Qt::DecorationRole);
}
int popcount = ci.pop;
/* set Popularity icon */
if (popcount == 0)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_0.png")), Qt::DecorationRole);
}
else if (popcount < 2)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_1.png")), Qt::DecorationRole);
}
else if (popcount < 4)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_2.png")), Qt::DecorationRole);
}
else if (popcount < 8)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_3.png")), Qt::DecorationRole);
}
else if (popcount < 16) {
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_4.png")), Qt::DecorationRole);
}
else
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_5.png")), Qt::DecorationRole);
}
} else {
chNameItem->setData(QVariant(QString(tr("Unknown Channel"))), Qt::DisplayRole);
chPopItem->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Unknown Channel\nNo Description"));
}
channel.append(chNameItem);
channel.append(chPopItem);
channel.append(chIdItem);
ownGroup->appendRow(channel);
}
}
void ChannelFeed::updateChannelListSub(std::list<std::string> &ids)
{
std::list<std::string>::iterator iit;
/* remove rows with groups before adding new ones */
model->item(SUBSCRIBED)->removeRows(0, model->item(SUBSCRIBED)->rowCount());
for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << std::endl;
#endif
QStandardItem *ownGroup = model->item(SUBSCRIBED);
QList<QStandardItem *> channel;
QStandardItem *chNameItem = new QStandardItem();
QStandardItem *chPopItem = new QStandardItem();
QStandardItem *chIdItem = new QStandardItem();
chNameItem->setSizeHint( QSize( 22,22 ) );
ChannelInfo ci;
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
chIdItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3").arg(QString::number(ci.pop)).arg(9999).arg(9999));
if (ci.pngImageLen != 0) {
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
chNameItem->setData(QIcon(chanImage), Qt::DecorationRole);
} else {
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
chNameItem->setData(QIcon(defaulImage), Qt::DecorationRole);
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
}
chNameItem->setIcon(QIcon(chanImage));
/* set Popularity icon */
int popcount = ci.pop;
if (popcount == 0)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_0.png")), Qt::DecorationRole);
}
else if (popcount < 2)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_1.png")), Qt::DecorationRole);
}
else if (popcount < 4)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_2.png")), Qt::DecorationRole);
}
else if (popcount < 8)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_3.png")), Qt::DecorationRole);
}
else if (popcount < 16)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_4.png")), Qt::DecorationRole);
}
else
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_5.png")), Qt::DecorationRole);
}
if (popcount == 0) {
chPopItem->setIcon(QIcon(":/images/hot_0.png"));
} else if (popcount < 2) {
chPopItem->setIcon(QIcon(":/images/hot_1.png"));
} else if (popcount < 4) {
chPopItem->setIcon(QIcon(":/images/hot_2.png"));
} else if (popcount < 8) {
chPopItem->setIcon(QIcon(":/images/hot_3.png"));
} else if (popcount < 16) {
chPopItem->setIcon(QIcon(":/images/hot_4.png"));
} else {
chNameItem->setData(QVariant(QString(tr("Unknown Channel"))), Qt::DisplayRole);
chPopItem->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Unknown Channel\nNo Description"));
chPopItem->setIcon(QIcon(":/images/hot_5.png"));
}
}
channel.append(chNameItem);
channel.append(chPopItem);
channel.append(chIdItem);
ownGroup->appendRow(channel);
/* remove all items not in list */
int row = 0;
int rowCount = groupItem->rowCount();
while (row < rowCount) {
std::string channelId = groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString().toStdString();
for (iit = channelInfos.begin(); iit != channelInfos.end(); iit++) {
if (iit->channelId == channelId) {
break;
}
}
}
void ChannelFeed::updateChannelListPop(std::list<std::string> &ids)
{
std::list<std::string>::iterator iit;
/* remove rows with groups before adding new ones */
model->item(POPULAR)->removeRows(0, model->item(POPULAR)->rowCount());
for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << std::endl;
#endif
QStandardItem *ownGroup = model->item(POPULAR);
QList<QStandardItem *> channel;
QStandardItem *chNameItem = new QStandardItem();
QStandardItem *chPopItem = new QStandardItem();
QStandardItem *chIdItem = new QStandardItem();
chNameItem->setSizeHint( QSize( 22,22 ) );
ChannelInfo ci;
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
chIdItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3").arg(QString::number(ci.pop)).arg(9999).arg(9999));
if(ci.pngImageLen != 0){
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
chNameItem->setData(QIcon(chanImage), Qt::DecorationRole);
if (iit == channelInfos.end()) {
groupItem->removeRow(row);
rowCount = groupItem->rowCount();
} else {
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
chNameItem->setData(QIcon(defaulImage), Qt::DecorationRole);
row++;
}
}
}
/* set Popularity icon */
int popcount = ci.pop;
if (popcount == 0)
void ChannelFeed::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_0.png")), Qt::DecorationRole);
}
else if (popcount < 2)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_1.png")), Qt::DecorationRole);
}
else if (popcount < 4)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_2.png")), Qt::DecorationRole);
}
else if (popcount < 8)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_3.png")), Qt::DecorationRole);
}
else if (popcount < 16) {
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_4.png")), Qt::DecorationRole);
}
else
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_5.png")), Qt::DecorationRole);
updateMessageSummaryList(channelId.toStdString());
}
void ChannelFeed::updateMessageSummaryList(const std::string &channelId)
{
int channelItems[2] = { OWN, SUBSCRIBED };
for (int channelItem = 0; channelItem < 2; channelItem++) {
QStandardItem *groupItem = model->item(channelItem);
if (groupItem == NULL) {
continue;
}
int row;
int rowCount = groupItem->rowCount();
for (row = 0; row < rowCount; row++) {
std::string rowChannelId = groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString().toStdString();
if (rowChannelId.empty()) {
continue;
}
if (channelId.empty() || rowChannelId == channelId) {
/* calculate unread messages */
unsigned int newMessageCount = 0;
unsigned int unreadMessageCount = 0;
rsChannels->getMessageCount(rowChannelId, newMessageCount, unreadMessageCount);
QStandardItem *item = groupItem->child(row, COLUMN_NAME);
QString title = item->data(ROLE_CHANNEL_TITLE).toString();
QFont font = item->font();
if (unreadMessageCount) {
title += " (" + QString::number(unreadMessageCount) + ")";
font.setBold(true);
} else {
chNameItem->setData(QVariant(QString(tr("Unknown Channel"))), Qt::DisplayRole);
chPopItem->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Unknown Channel\nNo Description"));
font.setBold(false);
}
channel.append(chNameItem);
channel.append(chPopItem);
channel.append(chIdItem);
ownGroup->appendRow(channel);
item->setText(title);
item->setFont(font);
if (channelId.empty() == false) {
/* calculate only this channel */
break;
}
}
void ChannelFeed::updateChannelListOther(std::list<std::string> &ids)
{
std::list<std::string>::iterator iit;
/* remove rows with groups before adding new ones */
model->item(OTHER)->removeRows(0, model->item(OTHER)->rowCount());
for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << std::endl;
#endif
QStandardItem *ownGroup = model->item(OTHER);
QList<QStandardItem *> channel;
QStandardItem *chNameItem = new QStandardItem();
QStandardItem *chPopItem = new QStandardItem();
QStandardItem *chIdItem = new QStandardItem();
chNameItem->setSizeHint( QSize( 22,22 ) );
ChannelInfo ci;
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
chIdItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3"
).arg(QString::number(ci.pop)).arg(9999).arg(9999));
if(ci.pngImageLen != 0){
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
chNameItem->setData(QIcon(chanImage), Qt::DecorationRole);
}else{
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
chNameItem->setData(QIcon(defaulImage), Qt::DecorationRole);
}
/* set Popularity icon */
int popcount = ci.pop;
if (popcount == 0)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_0.png")), Qt::DecorationRole);
}
else if (popcount < 2)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_1.png")), Qt::DecorationRole);
}
else if (popcount < 4)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_2.png")), Qt::DecorationRole);
}
else if (popcount < 8)
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_3.png")), Qt::DecorationRole);
}
else if (popcount < 16) {
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_4.png")), Qt::DecorationRole);
}
else
{
chPopItem->setData(QIcon(QString::fromUtf8(":/images/hot_5.png")), Qt::DecorationRole);
}
} else {
chNameItem->setData(QVariant(QString(tr("Unknown Channel"))), Qt::DisplayRole);
chPopItem->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Unknown Channel\nNo Description"));
}
channel.append(chNameItem);
channel.append(chPopItem);
channel.append(chIdItem);
ownGroup->appendRow(channel);
}
}
@ -679,15 +508,16 @@ static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMs
void ChannelFeed::updateChannelMsgs()
{
if (!rsChannels)
if (!rsChannels) {
return;
}
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci))
{
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
postButton->setEnabled(false);
subscribeButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
setAllAsReadButton->setEnabled(false);
nameLabel->setText(tr("No Channel Selected"));
iconLabel->setPixmap(QPixmap(":/images/channels.png"));
iconLabel->setEnabled(false);
@ -695,7 +525,6 @@ void ChannelFeed::updateChannelMsgs()
}
if (ci.pngImageLen != 0) {
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
iconLabel->setPixmap(chanImage);
@ -716,30 +545,25 @@ void ChannelFeed::updateChannelMsgs()
nameLabel->setText(channelStr.arg(cname));
/* do buttons */
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
{
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
subscribeButton->setEnabled(false);
unsubscribeButton->setEnabled(true);
}
else
{
setAllAsReadButton->setEnabled(true);
} else {
subscribeButton->setEnabled(true);
unsubscribeButton->setEnabled(false);
setAllAsReadButton->setEnabled(false);
}
if (ci.channelFlags & RS_DISTRIB_PUBLISH)
{
if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
postButton->setEnabled(true);
}
else
{
} else {
postButton->setEnabled(false);
}
/* replace all the messages with new ones */
std::list<ChanMsgItem *>::iterator mit;
for(mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++)
{
for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) {
delete (*mit);
}
mChanMsgItems.clear();
@ -751,8 +575,7 @@ void ChannelFeed::updateChannelMsgs()
msgs.sort(sortChannelMsgSummary);
for(it = msgs.begin(); it != msgs.end(); it++)
{
for(it = msgs.begin(); it != msgs.end(); it++) {
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
mChanMsgItems.push_back(cmi);
@ -760,17 +583,17 @@ void ChannelFeed::updateChannelMsgs()
}
}
void ChannelFeed::unsubscribeChannel()
{
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
if (rsChannels) {
rsChannels->channelSubscribe(mChannelId, false);
}
updateChannelMsgs();
}
@ -781,33 +604,53 @@ void ChannelFeed::subscribeChannel()
std::cerr << "ChannelFeed::subscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
if (rsChannels) {
rsChannels->channelSubscribe(mChannelId, true);
}
updateChannelMsgs();
}
void ChannelFeed::toggleSelection(const QModelIndex &index)
{
QItemSelectionModel *selectionModel = treeView->selectionModel();
if (index.child(0, 0).isValid())
selectionModel->select(index, QItemSelectionModel::Toggle);
}
void ChannelFeed::showChannelDetails()
{
if (mChannelId == "")
{
if (mChannelId.empty()) {
return;
}
if (!rsChannels)
if (!rsChannels) {
return;
}
ChannelDetails channelui (this);
channelui.showDetails(mChannelId);
channelui.exec();
}
void ChannelFeed::setAllAsReadClicked()
{
if (mChannelId.empty()) {
return;
}
if (!rsChannels) {
return;
}
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChannelId, ci) == false) {
return;
}
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
std::list<ChannelMsgSummary> msgs;
std::list<ChannelMsgSummary>::iterator it;
rsChannels->getChannelMsgList(mChannelId, msgs);
for(it = msgs.begin(); it != msgs.end(); it++) {
rsChannels->setMessageStatus(mChannelId, it->msgId, CHANNEL_MSG_STATUS_READ, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
}
}
}

View file

@ -22,6 +22,8 @@
#ifndef _CHANNEL_FEED_DIALOG_H
#define _CHANNEL_FEED_DIALOG_H
#include <retroshare/rschannels.h>
#include "mainpage.h"
#include "RsAutoUpdatePage.h"
@ -36,6 +38,7 @@
class ChanMsgItem;
class QStandardItemModel;
class QStandardItem;
class ChannelFeed : public RsAutoUpdatePage, public FeedHolder, private Ui::ChannelFeed
{
@ -54,13 +57,9 @@ public:
virtual void updateDisplay();
public slots:
void selectChannel( std::string );
void selectChannel(const QModelIndex &);
void toggleSelection(const QModelIndex &);
void selectChannel(QModelIndex index);
private slots:
void channelListCustomPopupMenu( QPoint point );
void createChannel();
@ -69,6 +68,7 @@ private slots:
void subscribeChannel();
void unsubscribeChannel();
void setAllAsReadClicked();
void createMsg();
@ -77,15 +77,14 @@ private slots:
void editChannelDetail();
void shareKey();
private:
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
private:
void updateChannelList();
void updateChannelListOwn(std::list<std::string> &ids);
void updateChannelListSub(std::list<std::string> &ids);
void updateChannelListPop(std::list<std::string> &ids);
void updateChannelListOther(std::list<std::string> &ids);
void fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos);
void updateChannelMsgs();
void updateMessageSummaryList(const std::string &channelId);
QStandardItemModel *model;
@ -98,15 +97,6 @@ private:
QFont mChannelFont;
QFont itemFont;
QAction* postchannelAct;
QAction* subscribechannelAct;
QAction* unsubscribechannelAct;
QAction* channeldetailsAct;
QAction* restoreKeysAct;
QAction* editChannelDetailAct;
QAction* shareKeyAct;
};

View file

@ -469,7 +469,7 @@ border-image: url(:/images/btn_26_pressed.png) 4;
</spacer>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="setallreadtoolButton">
<widget class="QToolButton" name="setAllAsReadButton">
<property name="minimumSize">
<size>
<width>26</width>

View file

@ -68,6 +68,7 @@
#include <retroshare/rspeers.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rsforums.h>
#include <retroshare/rschannels.h>
#include <retroshare/rsnotify.h>
#include "gui/connect/ConnectFriendWizard.h"
@ -218,7 +219,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
messageAction = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
channelAction = createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
#ifdef BLOGS
ui.stackPages->add(blogsFeed = new BlogsDialog(ui.stackPages),
@ -308,6 +309,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
/* call once */
updateMessages();
updateForums();
updateChannels(NOTIFY_TYPE_ADD);
privateChatChanged(NOTIFY_LIST_PRIVATE_INCOMING_CHAT, NOTIFY_TYPE_ADD);
idle = new Idle();
@ -403,6 +405,11 @@ void MainWindow::createTrayIcon()
trayIconForums->setIcon(QIcon(":/images/konversation16.png"));
connect(trayIconForums, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconForumsClicked(QSystemTrayIcon::ActivationReason)));
// Create the tray icon for channels
trayIconChannels = new QSystemTrayIcon(this);
trayIconChannels->setIcon(QIcon(":/images/channels16.png"));
connect(trayIconChannels, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconChannelsClicked(QSystemTrayIcon::ActivationReason)));
// Create the tray icon for chat
trayIconChat = new QSystemTrayIcon(this);
trayIconChat->setIcon(QIcon(":/images/chat.png"));
@ -458,9 +465,9 @@ void MainWindow::updateForums()
rsForums->getMessageCount("", newMessageCount, unreadMessageCount);
if (newMessageCount) {
forumAction->setIcon(QIcon(QPixmap(":/images/konversation_new.png"))) ;
forumAction->setIcon(QIcon(":/images/konversation_new.png")) ;
} else {
forumAction->setIcon(QIcon(QPixmap(":/images/konversation.png"))) ;
forumAction->setIcon(QIcon(IMAGE_FORUMS)) ;
}
if (newMessageCount) {
@ -475,6 +482,30 @@ void MainWindow::updateForums()
}
}
void MainWindow::updateChannels(int type)
{
unsigned int newMessageCount = 0;
unsigned int unreadMessageCount = 0;
rsChannels->getMessageCount("", newMessageCount, unreadMessageCount);
if (newMessageCount) {
channelAction->setIcon(QIcon(":/images/channels_new32.png")) ;
} else {
channelAction->setIcon(QIcon(IMAGE_CHANNELS)) ;
}
if (newMessageCount) {
if (newMessageCount > 1) {
trayIconChannels->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new messages").arg(newMessageCount));
} else {
trayIconChannels->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new message").arg(newMessageCount));
}
trayIconChannels->show();
} else {
trayIconChannels->hide();
}
}
void MainWindow::updateStatus()
{
// This call is essential to remove locks due to QEventLoop re-entrance while asking gpg passwds. Dont' remove it!
@ -831,6 +862,13 @@ void MainWindow::trayIconForumsClicked(QSystemTrayIcon::ActivationReason e)
}
}
void MainWindow::trayIconChannelsClicked(QSystemTrayIcon::ActivationReason e)
{
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
showWindow(MainWindow::Channels);
}
}
void MainWindow::trayIconChatClicked(QSystemTrayIcon::ActivationReason e)
{
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {

View file

@ -141,6 +141,7 @@ public slots:
void checkAndSetIdle(int idleTime);
void updateMessages();
void updateForums();
void updateChannels(int type);
void privateChatChanged(int list, int type);
protected:
@ -161,6 +162,7 @@ private slots:
void toggleVisibilitycontextmenu();
void trayIconMessagesClicked(QSystemTrayIcon::ActivationReason e);
void trayIconForumsClicked(QSystemTrayIcon::ActivationReason e);
void trayIconChannelsClicked(QSystemTrayIcon::ActivationReason e);
void trayIconChatClicked(QSystemTrayIcon::ActivationReason e);
/** Toolbar fns. */
@ -225,6 +227,7 @@ private:
QSystemTrayIcon *trayIcon;
QSystemTrayIcon *trayIconMessages;
QSystemTrayIcon *trayIconForums;
QSystemTrayIcon *trayIconChannels;
QSystemTrayIcon *trayIconChat;
QAction *toggleVisibilityAction, *toolAct;
QMenu *trayMenu;
@ -238,6 +241,7 @@ private:
QAction *messageAction;
QAction *forumAction;
QAction *channelAction;
/* Status */
std::set <QObject*> m_apStatusObjects; // added objects for status
@ -254,4 +258,3 @@ private:
};
#endif

View file

@ -26,6 +26,7 @@
#include "FeedHolder.h"
#include "SubFileItem.h"
#include "gui/notifyqt.h"
#include <retroshare/rschannels.h>
@ -46,6 +47,8 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
setAttribute ( Qt::WA_DeleteOnClose, true );
m_inUpdateItemStatic = false;
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
@ -55,13 +58,15 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) );
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) );
connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) );
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
downloadButton->hide();
playButton->hide();
small();
updateItemStatic();
updateItem();
}
@ -81,12 +86,15 @@ void ChanMsgItem::updateItemStatic()
if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi))
return;
m_inUpdateItemStatic = true;
QString title;
ChannelInfo ci;
rsChannels->getChannelInfo(mChanId, ci);
if (!mIsHome)
{
ChannelInfo ci;
rsChannels->getChannelInfo(mChanId, ci);
title = "Channel Feed: ";
title += QString::fromStdWString(ci.channelName);
titleLabel->setText(title);
@ -97,6 +105,8 @@ void ChanMsgItem::updateItemStatic()
} else {
unsubscribeButton->setEnabled(false);
}
readButton->setVisible(false);
newLabel->setVisible(false);
}
else
{
@ -109,6 +119,30 @@ void ChanMsgItem::updateItemStatic()
unsubscribeButton->setEnabled(false);
clearButton->hide();
unsubscribeButton->hide();
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
readButton->setVisible(true);
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
if ((status & CHANNEL_MSG_STATUS_READ) == 0 || (status & CHANNEL_MSG_STATUS_UNREAD_BY_USER)) {
readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
} else {
readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
if (status & CHANNEL_MSG_STATUS_READ) {
newLabel->setVisible(false);
} else {
newLabel->setVisible(true);
}
} else {
readButton->setVisible(false);
newLabel->setVisible(false);
}
}
msgLabel->setText(QString::fromStdWString(cmi.msg));
@ -155,6 +189,8 @@ void ChanMsgItem::updateItemStatic()
label->setPixmap(thumbnail);
label->setStyleSheet("QLabel#label{border: 2px solid #D3D3D3;border-radius: 3px;}");
}
m_inUpdateItemStatic = false;
}
@ -311,3 +347,28 @@ void ChanMsgItem::play()
}
}
}
void ChanMsgItem::readToggled(bool checked)
{
if (m_inUpdateItemStatic) {
return;
}
/* set always as read ... */
uint32_t statusNew = CHANNEL_MSG_STATUS_READ;
if (checked) {
/* ... and as unread by user */
statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER;
} else {
/* ... and as read by user */
statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER;
}
rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
}
void ChanMsgItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
{
if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) {
updateItemStatic();
}
}

View file

@ -51,6 +51,9 @@ private slots:
void download();
void play();
void readToggled(bool checked);
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
void updateItem();
private:
@ -61,11 +64,10 @@ private:
std::string mMsgId;
bool mIsHome;
bool m_inUpdateItemStatic;
std::list<SubFileItem *> mFileItems;
};
#endif

View file

@ -87,7 +87,7 @@ border-radius: 10px;}</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
<pixmap>:/images/thumb-default-video.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
@ -114,7 +114,7 @@ border-radius: 10px;}</string>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="7">
<item row="0" column="0" colspan="8">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -139,7 +139,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="7" colspan="3">
<item row="0" column="8" colspan="3">
<widget class="QLabel" name="datetimelabel">
<property name="font">
<font>
@ -156,7 +156,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0" colspan="10">
<item row="1" column="0" colspan="11">
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
@ -182,7 +182,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="6" colspan="2">
<item row="2" column="7" colspan="2">
<widget class="QPushButton" name="unsubscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -197,12 +197,12 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item row="2" column="8">
<item row="2" column="9">
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -217,12 +217,12 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item row="2" column="9">
<item row="2" column="10">
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -240,7 +240,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
@ -248,33 +248,33 @@ p, li { white-space: pre-wrap; }
<item row="2" column="1">
<widget class="QLabel" name="filelabel">
<property name="text">
<string notr="true">TextLabel</string>
<string notr="true">fileLabel</string>
</property>
</widget>
</item>
<item row="2" column="3">
<item row="2" column="4">
<widget class="QPushButton" name="downloadButton">
<property name="text">
<string>Download</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
</widget>
</item>
<item row="2" column="4">
<item row="2" column="5">
<widget class="QPushButton" name="playButton">
<property name="text">
<string>Play</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/player_play.png</normaloff>:/images/player_play.png</iconset>
</property>
</widget>
</item>
<item row="2" column="5">
<item row="2" column="6">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -290,6 +290,30 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="readButton">
<property name="icon">
<iconset>
<normaloff>:/images/message-state-unread.png</normaloff>:/images/message-state-unread.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="newLabel">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -349,15 +373,6 @@ border-radius: 10px;}</string>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View file

@ -58,6 +58,7 @@
<file>images/channels16.png</file>
<file>images/channels24.png</file>
<file>images/channels32.png</file>
<file>images/channels_new32.png</file>
<file>images/copyrslink.png</file>
<file>images/contacts24.png</file>
<file>images/connection.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -98,6 +98,11 @@ void NotifyQt::notifyPeerStatusChangedSummary()
emit peerStatusChangedSummary();
}
void NotifyQt::notifyChannelMsgReadSatusChanged(const std::string& channelId, const std::string& msgId, uint32_t status)
{
emit channelMsgReadSatusChanged(QString::fromStdString(channelId), QString::fromStdString(msgId), status);
}
void NotifyQt::notifyOwnStatusMessageChanged()
{
#ifdef NOTIFY_DEBUG
@ -226,6 +231,12 @@ void NotifyQt::notifyListChange(int list, int type)
#endif
emit forumsChanged(); // use connect with Qt::QueuedConnection
break;
case NOTIFY_LIST_CHANNELLIST_LOCKED:
#ifdef NOTIFY_DEBUG
std::cerr << "received channel msg changed" << std::endl ;
#endif
emit channelsChanged(type); // use connect with Qt::QueuedConnection
break;
case NOTIFY_LIST_PUBLIC_CHAT:
#ifdef NOTIFY_DEBUG
std::cerr << "received public chat changed" << std::endl ;

View file

@ -44,6 +44,7 @@ class NotifyQt: public QObject, public NotifyBase
virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state);
/* one or more peers has changed the states */
virtual void notifyPeerStatusChangedSummary();
virtual void notifyChannelMsgReadSatusChanged(const std::string& channelId, const std::string& msgId, uint32_t status);
virtual std::string askForPassword(const std::string& key_details,bool prev_is_bad) ;
@ -63,6 +64,7 @@ class NotifyQt: public QObject, public NotifyBase
void messagesChanged() const ;
void messagesTagsChanged() const;
void forumsChanged() const ; // use connect with Qt::QueuedConnection
void channelsChanged(int type) const ; // use connect with Qt::QueuedConnection
void configChanged() const ;
void logInfoChanged(const QString&) const ;
void chatStatusChanged(const QString&,const QString&,bool) const ;
@ -78,6 +80,7 @@ class NotifyQt: public QObject, public NotifyBase
void publicChatChanged(int type) const ;
void privateChatChanged(int list, int type) const ;
void groupsChanged(int type) const ;
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
/* Notify from GUI */
void chatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);

View file

@ -196,6 +196,7 @@ int main(int argc, char *argv[])
QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ;
QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ;
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection);
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&)));