mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-05 01:25:39 -05:00
improvements messages:
- save msgId in configuration file - enable previous improvements read/unread state and tags new function for creating backups of a file bool createBackup (std::string sFilename, unsigned int nCount = 5); currently its only available for windows compile. maybe there is a linux developer who change it for linux. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3064 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fe98568329
commit
342768e626
@ -428,6 +428,11 @@ uint32_t RsMsgSerialiser::sizeItem(RsMsgItem *item)
|
|||||||
s += item->msgbcc.TlvSize();
|
s += item->msgbcc.TlvSize();
|
||||||
s += item->attachment.TlvSize();
|
s += item->attachment.TlvSize();
|
||||||
|
|
||||||
|
if (m_bConfiguration) {
|
||||||
|
// serialise msgId too
|
||||||
|
s += 4;
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +472,12 @@ bool RsMsgSerialiser::serialiseItem(RsMsgItem *item, void *data, uint32_t *p
|
|||||||
ok &= item->msgbcc.SetTlv(data, tlvsize, &offset);
|
ok &= item->msgbcc.SetTlv(data, tlvsize, &offset);
|
||||||
|
|
||||||
ok &= item->attachment.SetTlv(data, tlvsize, &offset);
|
ok &= item->attachment.SetTlv(data, tlvsize, &offset);
|
||||||
|
|
||||||
|
if (m_bConfiguration) {
|
||||||
|
// serialise msgId too
|
||||||
|
ok &= setRawUInt32(data, tlvsize, &offset, item->msgId);
|
||||||
|
}
|
||||||
|
|
||||||
if (offset != tlvsize)
|
if (offset != tlvsize)
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
@ -521,6 +532,12 @@ RsMsgItem *RsMsgSerialiser::deserialiseItem(void *data, uint32_t *pktsize)
|
|||||||
ok &= item->msgbcc.GetTlv(data, rssize, &offset);
|
ok &= item->msgbcc.GetTlv(data, rssize, &offset);
|
||||||
ok &= item->attachment.GetTlv(data, rssize, &offset);
|
ok &= item->attachment.GetTlv(data, rssize, &offset);
|
||||||
|
|
||||||
|
if (m_bConfiguration) {
|
||||||
|
// deserialise msgId too
|
||||||
|
// ok &= getRawUInt32(data, rssize, &offset, &(item->msgId));
|
||||||
|
getRawUInt32(data, rssize, &offset, &(item->msgId)); //use this line for backward compatibility
|
||||||
|
}
|
||||||
|
|
||||||
if (offset != rssize)
|
if (offset != rssize)
|
||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
|
@ -179,12 +179,12 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|||||||
class RsMsgSerialiser: public RsSerialType
|
class RsMsgSerialiser: public RsSerialType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsMsgSerialiser()
|
RsMsgSerialiser(bool bConfiguration = false)
|
||||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_MSG)
|
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_MSG), m_bConfiguration (bConfiguration)
|
||||||
{ return; }
|
{ return; }
|
||||||
|
|
||||||
RsMsgSerialiser(uint16_t type)
|
RsMsgSerialiser(uint16_t type)
|
||||||
:RsSerialType(RS_PKT_VERSION_SERVICE, type)
|
:RsSerialType(RS_PKT_VERSION_SERVICE, type), m_bConfiguration (false)
|
||||||
{ return; }
|
{ return; }
|
||||||
|
|
||||||
virtual ~RsMsgSerialiser() { return; }
|
virtual ~RsMsgSerialiser() { return; }
|
||||||
@ -200,6 +200,7 @@ virtual uint32_t sizeItem(RsMsgItem *);
|
|||||||
virtual bool serialiseItem (RsMsgItem *item, void *data, uint32_t *size);
|
virtual bool serialiseItem (RsMsgItem *item, void *data, uint32_t *size);
|
||||||
virtual RsMsgItem *deserialiseItem(void *data, uint32_t *size);
|
virtual RsMsgItem *deserialiseItem(void *data, uint32_t *size);
|
||||||
|
|
||||||
|
bool m_bConfiguration; // is set to true for saving configuration (enables serialising msgId)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
@ -276,10 +276,15 @@ bool p3MsgService::saveConfiguration()
|
|||||||
std::string msgfile = Filename();
|
std::string msgfile = Filename();
|
||||||
std::string msgfiletmp = Filename()+".tmp";
|
std::string msgfiletmp = Filename()+".tmp";
|
||||||
|
|
||||||
|
if (RsDirUtil::createBackup (msgfile) == false) {
|
||||||
|
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "File backup error", "Error while backing up file " + msgfile);
|
||||||
|
// no error ?
|
||||||
|
}
|
||||||
|
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
RsSerialiser *rss = new RsSerialiser();
|
RsSerialiser *rss = new RsSerialiser();
|
||||||
rss->addSerialType(new RsMsgSerialiser());
|
rss->addSerialType(new RsMsgSerialiser(true)); // create serialiser for configuration
|
||||||
|
|
||||||
BinFileInterface *out = new BinFileInterface(msgfiletmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
BinFileInterface *out = new BinFileInterface(msgfiletmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
||||||
pqiarchive *pa_out = new pqiarchive(rss, out, BIN_FLAGS_WRITEABLE | BIN_FLAGS_NO_DELETE);
|
pqiarchive *pa_out = new pqiarchive(rss, out, BIN_FLAGS_WRITEABLE | BIN_FLAGS_NO_DELETE);
|
||||||
@ -312,39 +317,25 @@ bool p3MsgService::loadConfiguration(std::string &loadHash)
|
|||||||
std::string msgfile = Filename();
|
std::string msgfile = Filename();
|
||||||
|
|
||||||
RsSerialiser *rss = new RsSerialiser();
|
RsSerialiser *rss = new RsSerialiser();
|
||||||
rss->addSerialType(new RsMsgSerialiser());
|
rss->addSerialType(new RsMsgSerialiser(true)); // create serialiser for configuration
|
||||||
|
|
||||||
BinFileInterface *in = new BinFileInterface(msgfile.c_str(), BIN_FLAGS_READABLE | BIN_FLAGS_HASH_DATA);
|
BinFileInterface *in = new BinFileInterface(msgfile.c_str(), BIN_FLAGS_READABLE | BIN_FLAGS_HASH_DATA);
|
||||||
pqiarchive *pa_in = new pqiarchive(rss, in, BIN_FLAGS_READABLE);
|
pqiarchive *pa_in = new pqiarchive(rss, in, BIN_FLAGS_READABLE);
|
||||||
RsItem *item;
|
RsItem *item;
|
||||||
RsMsgItem *mitem;
|
RsMsgItem *mitem;
|
||||||
|
|
||||||
|
std::list<RsMsgItem*> items;
|
||||||
|
|
||||||
|
// load items and calculate next unique msgId
|
||||||
while((item = pa_in -> GetItem()))
|
while((item = pa_in -> GetItem()))
|
||||||
{
|
{
|
||||||
if (NULL != (mitem = dynamic_cast<RsMsgItem *>(item)))
|
if (NULL != (mitem = dynamic_cast<RsMsgItem *>(item)))
|
||||||
{
|
{
|
||||||
/* switch depending on the PENDING
|
|
||||||
* flags
|
|
||||||
*/
|
|
||||||
/* STORE MsgID */
|
/* STORE MsgID */
|
||||||
mitem->msgId = getNewUniqueMsgId();
|
if (mitem->msgId >= mMsgUniqueId) {
|
||||||
if (mitem -> msgFlags & RS_MSG_FLAGS_PENDING)
|
mMsgUniqueId = mitem->msgId + 1;
|
||||||
{
|
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
|
||||||
|
|
||||||
//std::cerr << "MSG_PENDING";
|
|
||||||
//std::cerr << std::endl;
|
|
||||||
//mitem->print(std::cerr);
|
|
||||||
|
|
||||||
msgOutgoing[mitem->msgId] = mitem;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
|
||||||
|
|
||||||
imsg[mitem->msgId] = mitem;
|
|
||||||
}
|
}
|
||||||
|
items.push_back(mitem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -352,9 +343,41 @@ bool p3MsgService::loadConfiguration(std::string &loadHash)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort items into lists
|
||||||
|
std::list<RsMsgItem*>::iterator it;
|
||||||
|
for (it = items.begin(); it != items.end(); it++)
|
||||||
|
{
|
||||||
|
mitem = *it;
|
||||||
|
|
||||||
|
/* STORE MsgID */
|
||||||
|
if (mitem->msgId == 0) {
|
||||||
|
mitem->msgId = getNewUniqueMsgId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* switch depending on the PENDING
|
||||||
|
* flags
|
||||||
|
*/
|
||||||
|
if (mitem -> msgFlags & RS_MSG_FLAGS_PENDING)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
//std::cerr << "MSG_PENDING";
|
||||||
|
//std::cerr << std::endl;
|
||||||
|
//mitem->print(std::cerr);
|
||||||
|
|
||||||
|
msgOutgoing[mitem->msgId] = mitem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
imsg[mitem->msgId] = mitem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string hashin = in->gethash();
|
std::string hashin = in->gethash();
|
||||||
|
|
||||||
delete pa_in;
|
delete pa_in;
|
||||||
|
|
||||||
if (hashin != loadHash)
|
if (hashin != loadHash)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
#include "pqi/pqinotify.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -428,6 +429,60 @@ bool RsDirUtil::renameFile(const std::string& from, const std::string& to)
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsDirUtil::createBackup (std::string sFilename, unsigned int nCount)
|
||||||
|
{
|
||||||
|
#ifdef WINDOWS_SYS
|
||||||
|
if (GetFileAttributes (sFilename.c_str ()) == -1) {
|
||||||
|
// file doesn't exist
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// search last backup
|
||||||
|
int nLast;
|
||||||
|
for (nLast = nCount; nLast >= 1; nLast--) {
|
||||||
|
std::ostringstream sStream;
|
||||||
|
sStream << sFilename << nLast << ".bak";
|
||||||
|
|
||||||
|
if (GetFileAttributes (sStream.str ().c_str ()) != -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete max backup
|
||||||
|
if (nLast == nCount) {
|
||||||
|
std::ostringstream sStream;
|
||||||
|
sStream << sFilename << nCount << ".bak";
|
||||||
|
if (DeleteFile (sStream.str ().c_str ()) == FALSE) {
|
||||||
|
getPqiNotify()->AddSysMessage (0, RS_SYS_WARNING, "File delete error", "Error while deleting file " + sStream.str ());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
nLast--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename backups
|
||||||
|
for (int nIndex = nLast; nIndex >= 1; nIndex--) {
|
||||||
|
std::ostringstream sStream;
|
||||||
|
sStream << sFilename << nIndex << ".bak";
|
||||||
|
std::ostringstream sStream1;
|
||||||
|
sStream1 << sFilename << nIndex + 1 << ".bak";
|
||||||
|
|
||||||
|
if (renameFile (sStream.str (), sStream1.str ()) == false) {
|
||||||
|
getPqiNotify()->AddSysMessage (0, RS_SYS_WARNING, "File rename error", "Error while renaming file " + sStream.str () + " to " + sStream1.str ());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy backup
|
||||||
|
std::ostringstream sStream;
|
||||||
|
sStream << sFilename << 1 << ".bak";
|
||||||
|
if (CopyFile (sFilename.c_str (), sStream.str ().c_str (), FALSE) == FALSE) {
|
||||||
|
getPqiNotify()->AddSysMessage (0, RS_SYS_WARNING, "File rename error", "Error while renaming file " + sFilename + " to " + sStream.str ());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0 // NOT ENABLED YET!
|
#if 0 // NOT ENABLED YET!
|
||||||
/************************* WIDE STRING ***************************/
|
/************************* WIDE STRING ***************************/
|
||||||
/************************* WIDE STRING ***************************/
|
/************************* WIDE STRING ***************************/
|
||||||
|
@ -44,6 +44,7 @@ std::string removeRootDirs(std::string path, std::string root);
|
|||||||
// Renames file from to file to. Files should be on the same file system.
|
// Renames file from to file to. Files should be on the same file system.
|
||||||
// returns true if succeed, false otherwise.
|
// returns true if succeed, false otherwise.
|
||||||
bool renameFile(const std::string& from,const std::string& to) ;
|
bool renameFile(const std::string& from,const std::string& to) ;
|
||||||
|
bool createBackup (std::string sFilename, unsigned int nCount = 5);
|
||||||
|
|
||||||
int breakupDirList(std::string path,
|
int breakupDirList(std::string path,
|
||||||
std::list<std::string> &subdirs);
|
std::list<std::string> &subdirs);
|
||||||
|
@ -230,9 +230,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) );
|
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) );
|
||||||
connect( ui.messagestreeView, SIGNAL(doubleClicked ( const QModelIndex& ) ) , this, SLOT( doubleClicked( const QModelIndex & ) ) );
|
connect( ui.messagestreeView, SIGNAL(doubleClicked ( const QModelIndex& ) ) , this, SLOT( doubleClicked( const QModelIndex & ) ) );
|
||||||
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
|
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
connect( ui.tagWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeTag ( int) ) );
|
connect( ui.tagWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeTag ( int) ) );
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
|
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
|
||||||
connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
|
connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
|
||||||
@ -366,15 +364,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
ui.listWidget->setCurrentRow(ROW_INBOX);
|
ui.listWidget->setCurrentRow(ROW_INBOX);
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
// create tag menu
|
// create tag menu
|
||||||
fillTags();
|
fillTags();
|
||||||
#else
|
|
||||||
ui.tagButton->setHidden(true);
|
|
||||||
|
|
||||||
ui.Tags_Button->setHidden(true);
|
|
||||||
ui.tagWidget->setHidden(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// create timer for navigation
|
// create timer for navigation
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
@ -424,11 +415,9 @@ void MessagesDialog::processSettings(bool bLoad)
|
|||||||
// state of message tree
|
// state of message tree
|
||||||
msgwheader->restoreState(Settings->value("MessageTree").toByteArray());
|
msgwheader->restoreState(Settings->value("MessageTree").toByteArray());
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
// state of tag list
|
// state of tag list
|
||||||
bValue = Settings->value("tagList", true).toBool();
|
bValue = Settings->value("tagList", true).toBool();
|
||||||
ui.Tags_Button->setChecked(bValue);
|
ui.Tags_Button->setChecked(bValue);
|
||||||
#endif
|
|
||||||
|
|
||||||
// state of splitter
|
// state of splitter
|
||||||
ui.msgSplitter->restoreState(Settings->value("Splitter").toByteArray());
|
ui.msgSplitter->restoreState(Settings->value("Splitter").toByteArray());
|
||||||
@ -439,10 +428,8 @@ void MessagesDialog::processSettings(bool bLoad)
|
|||||||
// state of message tree
|
// state of message tree
|
||||||
Settings->setValue("MessageTree", msgwheader->saveState());
|
Settings->setValue("MessageTree", msgwheader->saveState());
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
// state of tag list
|
// state of tag list
|
||||||
Settings->setValue("tagList", ui.Tags_Button->isChecked());
|
Settings->setValue("tagList", ui.Tags_Button->isChecked());
|
||||||
#endif
|
|
||||||
|
|
||||||
// state of splitter
|
// state of splitter
|
||||||
Settings->setValue("Splitter", ui.msgSplitter->saveState());
|
Settings->setValue("Splitter", ui.msgSplitter->saveState());
|
||||||
@ -454,7 +441,6 @@ void MessagesDialog::processSettings(bool bLoad)
|
|||||||
m_bProcessSettings = false;
|
m_bProcessSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
static void getMessageTags (RSettings *pConfig, QString msgId, QList<int> &tagIds)
|
static void getMessageTags (RSettings *pConfig, QString msgId, QList<int> &tagIds)
|
||||||
{
|
{
|
||||||
pConfig->beginGroup(CONFIG_SECTION_TAG);
|
pConfig->beginGroup(CONFIG_SECTION_TAG);
|
||||||
@ -699,7 +685,6 @@ void MessagesDialog::fillTags()
|
|||||||
|
|
||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// replaced by shortcut
|
// replaced by shortcut
|
||||||
//void MessagesDialog::keyPressEvent(QKeyEvent *e)
|
//void MessagesDialog::keyPressEvent(QKeyEvent *e)
|
||||||
@ -776,7 +761,6 @@ void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
|
|||||||
QList<int> RowsUnread;
|
QList<int> RowsUnread;
|
||||||
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread);
|
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread);
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
QAction *markAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Mark as read" ), this);
|
QAction *markAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Mark as read" ), this);
|
||||||
connect(markAsRead , SIGNAL(triggered()), this, SLOT(markAsRead()));
|
connect(markAsRead , SIGNAL(triggered()), this, SLOT(markAsRead()));
|
||||||
contextMnu.addAction(markAsRead);
|
contextMnu.addAction(markAsRead);
|
||||||
@ -796,7 +780,6 @@ void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
|
|||||||
// add tags
|
// add tags
|
||||||
contextMnu.addMenu(ui.tagButton->menu());
|
contextMnu.addMenu(ui.tagButton->menu());
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
#endif
|
|
||||||
|
|
||||||
QAction *removemsgAct;
|
QAction *removemsgAct;
|
||||||
if (nCount > 1) {
|
if (nCount > 1) {
|
||||||
@ -1159,7 +1142,6 @@ void MessagesDialog::changeBox(int)
|
|||||||
m_bInChange = false;
|
m_bInChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void MessagesDialog::changeTag(int)
|
void MessagesDialog::changeTag(int)
|
||||||
{
|
{
|
||||||
if (m_bInChange) {
|
if (m_bInChange) {
|
||||||
@ -1179,7 +1161,6 @@ void MessagesDialog::changeTag(int)
|
|||||||
|
|
||||||
m_bInChange = false;
|
m_bInChange = false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void InitIconAndFont(RSettings *pConfig, QStandardItem *pItem [COLUMN_COUNT], int nFlag)
|
static void InitIconAndFont(RSettings *pConfig, QStandardItem *pItem [COLUMN_COUNT], int nFlag)
|
||||||
{
|
{
|
||||||
@ -1208,7 +1189,6 @@ static void InitIconAndFont(RSettings *pConfig, QStandardItem *pItem [COLUMN_COU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
// show the locale "New" state
|
// show the locale "New" state
|
||||||
if (bNew == false) {
|
if (bNew == false) {
|
||||||
// check locale config
|
// check locale config
|
||||||
@ -1222,7 +1202,6 @@ static void InitIconAndFont(RSettings *pConfig, QStandardItem *pItem [COLUMN_COU
|
|||||||
} else {
|
} else {
|
||||||
pItem[COLUMN_READ]->setIcon(QIcon(":/images/message-mail-state-read.png"));
|
pItem[COLUMN_READ]->setIcon(QIcon(":/images/message-mail-state-read.png"));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// set font
|
// set font
|
||||||
for (int i = 0; i < COLUMN_COUNT; i++) {
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
||||||
@ -1258,9 +1237,7 @@ void MessagesDialog::insertMessages()
|
|||||||
unsigned int msgbox = 0;
|
unsigned int msgbox = 0;
|
||||||
bool bTrash = false;
|
bool bTrash = false;
|
||||||
bool bFill = true;
|
bool bFill = true;
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
int nTagId = 0;
|
int nTagId = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (m_eListMode) {
|
switch (m_eListMode) {
|
||||||
case LIST_NOTHING:
|
case LIST_NOTHING:
|
||||||
@ -1303,7 +1280,6 @@ void MessagesDialog::insertMessages()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
case LIST_TAG:
|
case LIST_TAG:
|
||||||
{
|
{
|
||||||
QListWidgetItem *pItem = ui.tagWidget->currentItem();
|
QListWidgetItem *pItem = ui.tagWidget->currentItem();
|
||||||
@ -1314,7 +1290,6 @@ void MessagesDialog::insertMessages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bFill = false;
|
bFill = false;
|
||||||
@ -1327,10 +1302,8 @@ void MessagesDialog::insertMessages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bFill) {
|
if (bFill) {
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
std::map<int, TagItem> TagItems;
|
std::map<int, TagItem> TagItems;
|
||||||
getTagItems(TagItems);
|
getTagItems(TagItems);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* search messages */
|
/* search messages */
|
||||||
std::list<MsgInfoSummary> msgToShow;
|
std::list<MsgInfoSummary> msgToShow;
|
||||||
@ -1348,14 +1321,12 @@ void MessagesDialog::insertMessages()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
} else if (m_eListMode == LIST_TAG) {
|
} else if (m_eListMode == LIST_TAG) {
|
||||||
QList<int> tagIds;
|
QList<int> tagIds;
|
||||||
getMessageTags (m_pConfig, QString::fromStdString(it->msgId), tagIds);
|
getMessageTags (m_pConfig, QString::fromStdString(it->msgId), tagIds);
|
||||||
if (qFind(tagIds.begin(), tagIds.end(), nTagId) == tagIds.end()) {
|
if (qFind(tagIds.begin(), tagIds.end(), nTagId) == tagIds.end()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1516,7 +1487,6 @@ void MessagesDialog::insertMessages()
|
|||||||
// Init icon and font
|
// Init icon and font
|
||||||
InitIconAndFont(m_pConfig, item, it->msgflags);
|
InitIconAndFont(m_pConfig, item, it->msgflags);
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
// Tags
|
// Tags
|
||||||
QList<int> tagIds;
|
QList<int> tagIds;
|
||||||
getMessageTags (m_pConfig, msgId, tagIds);
|
getMessageTags (m_pConfig, msgId, tagIds);
|
||||||
@ -1540,7 +1510,6 @@ void MessagesDialog::insertMessages()
|
|||||||
for (int i = 0; i < COLUMN_COUNT; i++) {
|
for (int i = 0; i < COLUMN_COUNT; i++) {
|
||||||
item[i]->setForeground(Brush);
|
item[i]->setForeground(Brush);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// No of Files.
|
// No of Files.
|
||||||
{
|
{
|
||||||
@ -1579,18 +1548,10 @@ void MessagesDialog::insertMessages()
|
|||||||
|
|
||||||
ui.messagestreeView->showColumn(COLUMN_ATTACHEMENTS);
|
ui.messagestreeView->showColumn(COLUMN_ATTACHEMENTS);
|
||||||
ui.messagestreeView->showColumn(COLUMN_SUBJECT);
|
ui.messagestreeView->showColumn(COLUMN_SUBJECT);
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
ui.messagestreeView->showColumn(COLUMN_READ);
|
ui.messagestreeView->showColumn(COLUMN_READ);
|
||||||
#else
|
|
||||||
ui.messagestreeView->hideColumn(COLUMN_READ);
|
|
||||||
#endif
|
|
||||||
ui.messagestreeView->showColumn(COLUMN_FROM);
|
ui.messagestreeView->showColumn(COLUMN_FROM);
|
||||||
ui.messagestreeView->showColumn(COLUMN_DATE);
|
ui.messagestreeView->showColumn(COLUMN_DATE);
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
ui.messagestreeView->showColumn(COLUMN_TAGS);
|
ui.messagestreeView->showColumn(COLUMN_TAGS);
|
||||||
#else
|
|
||||||
ui.messagestreeView->hideColumn(COLUMN_TAGS);
|
|
||||||
#endif
|
|
||||||
ui.messagestreeView->hideColumn(COLUMN_SRCID);
|
ui.messagestreeView->hideColumn(COLUMN_SRCID);
|
||||||
ui.messagestreeView->hideColumn(COLUMN_MSGID);
|
ui.messagestreeView->hideColumn(COLUMN_MSGID);
|
||||||
ui.messagestreeView->hideColumn(COLUMN_CONTENT);
|
ui.messagestreeView->hideColumn(COLUMN_CONTENT);
|
||||||
@ -1685,16 +1646,12 @@ void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
|||||||
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||||
if (bRead) {
|
if (bRead) {
|
||||||
// set as read in config
|
// set as read in config
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
m_pConfig->setValue(mid, false);
|
m_pConfig->setValue(mid, false);
|
||||||
#endif
|
|
||||||
// set message to read
|
// set message to read
|
||||||
rsMsgs->MessageRead(mid.toStdString());
|
rsMsgs->MessageRead(mid.toStdString());
|
||||||
} else {
|
} else {
|
||||||
// set as unread in config
|
// set as unread in config
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
m_pConfig->setValue(mid, true);
|
m_pConfig->setValue(mid, true);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
m_pConfig->endGroup();
|
m_pConfig->endGroup();
|
||||||
|
|
||||||
@ -1702,7 +1659,6 @@ void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void MessagesDialog::markAsRead()
|
void MessagesDialog::markAsRead()
|
||||||
{
|
{
|
||||||
QList<int> RowsUnread;
|
QList<int> RowsUnread;
|
||||||
@ -1720,7 +1676,6 @@ void MessagesDialog::markAsUnread()
|
|||||||
setMsgAsReadUnread (RowsRead, false);
|
setMsgAsReadUnread (RowsRead, false);
|
||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
|
void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
|
||||||
{
|
{
|
||||||
@ -2208,13 +2163,10 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
|
|
||||||
rsMsgs->getMessageSummaries(msgList);
|
rsMsgs->getMessageSummaries(msgList);
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
QMap<int, int> tagCount;
|
QMap<int, int> tagCount;
|
||||||
#endif
|
|
||||||
|
|
||||||
/*calculating the new messages*/
|
/*calculating the new messages*/
|
||||||
for (it = msgList.begin(); it != msgList.end(); it++) {
|
for (it = msgList.begin(); it != msgList.end(); it++) {
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
/* calcluate tag count */
|
/* calcluate tag count */
|
||||||
QList<int> tagIds;
|
QList<int> tagIds;
|
||||||
getMessageTags (m_pConfig, QString::fromStdString(it->msgId), tagIds);
|
getMessageTags (m_pConfig, QString::fromStdString(it->msgId), tagIds);
|
||||||
@ -2223,7 +2175,6 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
nCount++;
|
nCount++;
|
||||||
tagCount [*tagId] = nCount;
|
tagCount [*tagId] = nCount;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* calculate box */
|
/* calculate box */
|
||||||
if (it->msgflags & RS_MSG_TRASH) {
|
if (it->msgflags & RS_MSG_TRASH) {
|
||||||
@ -2238,13 +2189,11 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
newInboxCount++;
|
newInboxCount++;
|
||||||
} else {
|
} else {
|
||||||
// check locale config
|
// check locale config
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||||
if (m_pConfig->value(QString::fromStdString(it->msgId), false).toBool()) {
|
if (m_pConfig->value(QString::fromStdString(it->msgId), false).toBool()) {
|
||||||
newInboxCount++;
|
newInboxCount++;
|
||||||
}
|
}
|
||||||
m_pConfig->endGroup();
|
m_pConfig->endGroup();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RS_MSG_OUTBOX:
|
case RS_MSG_OUTBOX:
|
||||||
@ -2345,7 +2294,6 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
textItem = tr("Total Sent:") + " " + QString::number(newSentboxCount);
|
textItem = tr("Total Sent:") + " " + QString::number(newSentboxCount);
|
||||||
ui.totalSentbox_label->setText(textItem);
|
ui.totalSentbox_label->setText(textItem);
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
/* set tag counts */
|
/* set tag counts */
|
||||||
int nRowCount = ui.tagWidget->count();
|
int nRowCount = ui.tagWidget->count();
|
||||||
for (int nRow = 0; nRow < nRowCount; nRow++) {
|
for (int nRow = 0; nRow < nRowCount; nRow++) {
|
||||||
@ -2359,7 +2307,6 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
|
|
||||||
pItem->setText(sText);
|
pItem->setText(sText);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** clear Filter **/
|
/** clear Filter **/
|
||||||
@ -2369,7 +2316,6 @@ void MessagesDialog::clearFilter()
|
|||||||
ui.filterPatternLineEdit->setFocus();
|
ui.filterPatternLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void MessagesDialog::tagAboutToShow()
|
void MessagesDialog::tagAboutToShow()
|
||||||
{
|
{
|
||||||
// activate actions from the first selected row
|
// activate actions from the first selected row
|
||||||
@ -2490,4 +2436,3 @@ void MessagesDialog::tagTriggered(QAction *pAction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -37,9 +37,6 @@
|
|||||||
|
|
||||||
class RSettings;
|
class RSettings;
|
||||||
|
|
||||||
// Thunder: need a static msgId
|
|
||||||
//#define STATIC_MSGID
|
|
||||||
|
|
||||||
class MessagesDialog : public MainPage
|
class MessagesDialog : public MainPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -50,11 +47,9 @@ public:
|
|||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
~MessagesDialog();
|
~MessagesDialog();
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
static void initStandardTagItems(std::map<int, TagItem> &Items);
|
static void initStandardTagItems(std::map<int, TagItem> &Items);
|
||||||
void getTagItems(std::map<int, TagItem> &Items);
|
void getTagItems(std::map<int, TagItem> &Items);
|
||||||
void setTagItems(std::map<int, TagItem> &Items);
|
void setTagItems(std::map<int, TagItem> &Items);
|
||||||
#endif
|
|
||||||
|
|
||||||
// replaced by shortcut
|
// replaced by shortcut
|
||||||
// virtual void keyPressEvent(QKeyEvent *) ;
|
// virtual void keyPressEvent(QKeyEvent *) ;
|
||||||
@ -71,9 +66,7 @@ private slots:
|
|||||||
void msgfilelistWidgetCostumPopupMenu(QPoint);
|
void msgfilelistWidgetCostumPopupMenu(QPoint);
|
||||||
|
|
||||||
void changeBox( int newrow );
|
void changeBox( int newrow );
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void changeTag( int newrow );
|
void changeTag( int newrow );
|
||||||
#endif
|
|
||||||
void updateCurrentMessage();
|
void updateCurrentMessage();
|
||||||
void currentChanged(const QModelIndex&);
|
void currentChanged(const QModelIndex&);
|
||||||
void clicked(const QModelIndex&);
|
void clicked(const QModelIndex&);
|
||||||
@ -94,10 +87,8 @@ private slots:
|
|||||||
void removemessage();
|
void removemessage();
|
||||||
void undeletemessage();
|
void undeletemessage();
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void markAsRead();
|
void markAsRead();
|
||||||
void markAsUnread();
|
void markAsUnread();
|
||||||
#endif
|
|
||||||
|
|
||||||
void anchorClicked (const QUrl &);
|
void anchorClicked (const QUrl &);
|
||||||
|
|
||||||
@ -117,10 +108,8 @@ private slots:
|
|||||||
void filterColumnChanged();
|
void filterColumnChanged();
|
||||||
|
|
||||||
void clearFilter();
|
void clearFilter();
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void tagTriggered(QAction *pAction);
|
void tagTriggered(QAction *pAction);
|
||||||
void tagAboutToShow();
|
void tagAboutToShow();
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class LockUpdate
|
class LockUpdate
|
||||||
@ -153,19 +142,12 @@ private:
|
|||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
|
|
||||||
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
|
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
void fillTags();
|
void fillTags();
|
||||||
#endif
|
|
||||||
bool m_bProcessSettings;
|
bool m_bProcessSettings;
|
||||||
bool m_bInChange;
|
bool m_bInChange;
|
||||||
int m_nLockUpdate; // use with LockUpdate
|
int m_nLockUpdate; // use with LockUpdate
|
||||||
|
|
||||||
enum { LIST_NOTHING,
|
enum { LIST_NOTHING, LIST_BOX, LIST_TAG } m_eListMode;
|
||||||
LIST_BOX,
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
LIST_TAG
|
|
||||||
#endif
|
|
||||||
} m_eListMode;
|
|
||||||
|
|
||||||
std::string mCurrCertId;
|
std::string mCurrCertId;
|
||||||
std::string mCurrMsgId;
|
std::string mCurrMsgId;
|
||||||
|
@ -59,12 +59,10 @@ MessagePage::save(QString &errmsg)
|
|||||||
{
|
{
|
||||||
Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
|
Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
MessagesDialog *pPage = (MessagesDialog*) MainWindow::getPage (MainWindow::Messages);
|
MessagesDialog *pPage = (MessagesDialog*) MainWindow::getPage (MainWindow::Messages);
|
||||||
if (pPage) {
|
if (pPage) {
|
||||||
pPage->setTagItems (m_TagItems);
|
pPage->setTagItems (m_TagItems);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -75,7 +73,6 @@ MessagePage::load()
|
|||||||
{
|
{
|
||||||
ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate());
|
ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate());
|
||||||
|
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
MessagesDialog *pPage = (MessagesDialog*) MainWindow::getPage (MainWindow::Messages);
|
MessagesDialog *pPage = (MessagesDialog*) MainWindow::getPage (MainWindow::Messages);
|
||||||
if (pPage) {
|
if (pPage) {
|
||||||
pPage->getTagItems (m_TagItems);
|
pPage->getTagItems (m_TagItems);
|
||||||
@ -90,13 +87,6 @@ MessagePage::load()
|
|||||||
ui.deletepushButton->setEnabled(false);
|
ui.deletepushButton->setEnabled(false);
|
||||||
ui.defaultTagButton->setEnabled(false);
|
ui.defaultTagButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ui.tags_listWidget->setEnabled(false);
|
|
||||||
ui.addpushButton->setEnabled(false);
|
|
||||||
ui.editpushButton->setEnabled(false);
|
|
||||||
ui.deletepushButton->setEnabled(false);
|
|
||||||
ui.defaultTagButton->setEnabled(false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill items
|
// fill items
|
||||||
@ -173,9 +163,7 @@ void MessagePage::deleteTag()
|
|||||||
|
|
||||||
void MessagePage::defaultTag()
|
void MessagePage::defaultTag()
|
||||||
{
|
{
|
||||||
#ifdef STATIC_MSGID
|
|
||||||
MessagesDialog::initStandardTagItems(m_TagItems);
|
MessagesDialog::initStandardTagItems(m_TagItems);
|
||||||
#endif
|
|
||||||
fillTagItems();
|
fillTagItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user