mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -04:00
RsAutoUpdatePage
- Changed the timer of RsAutoUpdatePage to a single-shot timer. The update can take longer than the given timer interval. Changed status service: - send status when the peer connects (new monitor) - send status to all online peers only when user changed it (not in every timer tick) MessengerWindow: - remove load and save of custom state string in settings p3ChatService::sendCustomState - send empty custom state string too git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3307 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f7282edf33
commit
e3e4c97369
15 changed files with 145 additions and 133 deletions
|
@ -47,6 +47,13 @@ const uint32_t RS_STATUS_INACTIVE = 0x0004;
|
||||||
*/
|
*/
|
||||||
class StatusInfo
|
class StatusInfo
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
StatusInfo()
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
time_stamp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string id;
|
std::string id;
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
|
@ -62,6 +69,12 @@ class RsStatus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This retrieves the own status info
|
||||||
|
* @param statusInfo is populated with own status
|
||||||
|
*/
|
||||||
|
virtual bool getOwnStatus(StatusInfo& statusInfo) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This retrieves the status info on the client's peers
|
* This retrieves the status info on the client's peers
|
||||||
* @param statusInfo is populated with client's peer's status
|
* @param statusInfo is populated with client's peer's status
|
||||||
|
@ -70,10 +83,11 @@ class RsStatus
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send the client's status to his/her peers
|
* send the client's status to his/her peers
|
||||||
* @param statusInfo the status of the peers
|
* @param id the peer to send the status (empty, send to all)
|
||||||
|
* @param status the status of the peers
|
||||||
* @return will return false if status info does not belong to client
|
* @return will return false if status info does not belong to client
|
||||||
*/
|
*/
|
||||||
virtual bool sendStatus(StatusInfo& statusInfo) = 0;
|
virtual bool sendStatus(std::string id, uint32_t status) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks to see if any status items have been received
|
* checks to see if any status items have been received
|
||||||
|
|
|
@ -37,15 +37,19 @@ p3Status::~p3Status(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3Status::getOwnStatus(StatusInfo& statusInfo){
|
||||||
|
|
||||||
|
return mStatusSrv->getOwnStatus(statusInfo);
|
||||||
|
}
|
||||||
|
|
||||||
bool p3Status::getStatus(std::list<StatusInfo >& statusInfo){
|
bool p3Status::getStatus(std::list<StatusInfo >& statusInfo){
|
||||||
|
|
||||||
return mStatusSrv->getStatus(statusInfo);
|
return mStatusSrv->getStatus(statusInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3Status::sendStatus(std::string id, uint32_t status){
|
||||||
|
|
||||||
bool p3Status::sendStatus(StatusInfo& statusInfo){
|
return mStatusSrv->sendStatus(id, status);
|
||||||
|
|
||||||
return mStatusSrv->sendStatus(statusInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Status::statusAvailable(){
|
bool p3Status::statusAvailable(){
|
||||||
|
|
|
@ -43,8 +43,9 @@ public:
|
||||||
virtual ~p3Status();
|
virtual ~p3Status();
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool getOwnStatus(StatusInfo& statusInfo);
|
||||||
virtual bool getStatus(std::list<StatusInfo>& statusInfo);
|
virtual bool getStatus(std::list<StatusInfo>& statusInfo);
|
||||||
virtual bool sendStatus(StatusInfo& statusInfo);
|
virtual bool sendStatus(std::string id, uint32_t status);
|
||||||
virtual bool statusAvailable();
|
virtual bool statusAvailable();
|
||||||
|
|
||||||
virtual void getStatusString(uint32_t status, std::string& statusString);
|
virtual void getStatusString(uint32_t status, std::string& statusString);
|
||||||
|
|
|
@ -2243,6 +2243,7 @@ int RsServer::StartupRetroShare()
|
||||||
mConnMgr->addMonitor(mCacheStrapper);
|
mConnMgr->addMonitor(mCacheStrapper);
|
||||||
mConnMgr->addMonitor(ad);
|
mConnMgr->addMonitor(ad);
|
||||||
mConnMgr->addMonitor(msgSrv);
|
mConnMgr->addMonitor(msgSrv);
|
||||||
|
mConnMgr->addMonitor(mStatusSrv);
|
||||||
|
|
||||||
/* must also add the controller as a Monitor...
|
/* must also add the controller as a Monitor...
|
||||||
* a little hack to get it to work.
|
* a little hack to get it to work.
|
||||||
|
|
|
@ -654,16 +654,10 @@ void p3ChatService::sendCustomState(const std::string& peer_id){
|
||||||
std::cerr << "p3chatservice: sending requested status string for peer " << peer_id << std::endl ;
|
std::cerr << "p3chatservice: sending requested status string for peer " << peer_id << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(_custom_status_string != ""){
|
RsChatStatusItem *cs = makeOwnCustomStateStringItem();
|
||||||
RsChatStatusItem *cs = makeOwnCustomStateStringItem();
|
cs->PeerId(peer_id);
|
||||||
cs->PeerId(peer_id);
|
|
||||||
|
|
||||||
sendItem(cs);
|
sendItem(cs);
|
||||||
}else{
|
|
||||||
#ifdef CHAT_DEBUG
|
|
||||||
std::cerr << "doing nothing" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::loadList(std::list<RsItem*> load)
|
bool p3ChatService::loadList(std::list<RsItem*> load)
|
||||||
|
|
|
@ -53,6 +53,23 @@ p3StatusService::~p3StatusService()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3StatusService::getOwnStatus(StatusInfo& statusInfo)
|
||||||
|
{
|
||||||
|
std::map<std::string, StatusInfo>::iterator it;
|
||||||
|
std::string ownId = mConnMgr->getOwnId();
|
||||||
|
|
||||||
|
RsStackMutex stack(mStatusMtx);
|
||||||
|
it = mStatusInfoMap.find(ownId);
|
||||||
|
|
||||||
|
if (it == mStatusInfoMap.end()){
|
||||||
|
std::cerr << "p3StatusService::saveList() :" << "Did not find your status" << ownId << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
statusInfo = it->second;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3StatusService::getStatus(std::list<StatusInfo>& statusInfo)
|
bool p3StatusService::getStatus(std::list<StatusInfo>& statusInfo)
|
||||||
{
|
{
|
||||||
|
@ -128,15 +145,17 @@ bool p3StatusService::getStatus(std::list<StatusInfo>& statusInfo)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3StatusService::sendStatus(StatusInfo& statusInfo)
|
/* id = "", status is sent to all online peers */
|
||||||
|
bool p3StatusService::sendStatus(const std::string &id, uint32_t status)
|
||||||
{
|
{
|
||||||
|
StatusInfo statusInfo;
|
||||||
std::list<std::string> onlineList;
|
std::list<std::string> onlineList;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mStatusMtx);
|
RsStackMutex stack(mStatusMtx);
|
||||||
|
|
||||||
if(statusInfo.id != mConnMgr->getOwnId())
|
statusInfo.id = mConnMgr->getOwnId();
|
||||||
return false;
|
statusInfo.status = status;
|
||||||
|
|
||||||
// don't save inactive status
|
// don't save inactive status
|
||||||
if(statusInfo.status != RS_STATUS_INACTIVE){
|
if(statusInfo.status != RS_STATUS_INACTIVE){
|
||||||
|
@ -147,15 +166,18 @@ bool p3StatusService::sendStatus(StatusInfo& statusInfo)
|
||||||
std::pair<std::string, StatusInfo> pr(statusInfo.id, statusInfo);
|
std::pair<std::string, StatusInfo> pr(statusInfo.id, statusInfo);
|
||||||
mStatusInfoMap.insert(pr);
|
mStatusInfoMap.insert(pr);
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
}else
|
} else if(mStatusInfoMap[statusInfo.id].status != statusInfo.status){
|
||||||
if(mStatusInfoMap[statusInfo.id].status != statusInfo.status){
|
|
||||||
|
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
mStatusInfoMap[statusInfo.id] = statusInfo;
|
mStatusInfoMap[statusInfo.id] = statusInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mConnMgr->getOnlineList(onlineList);
|
if (id.empty()) {
|
||||||
|
mConnMgr->getOnlineList(onlineList);
|
||||||
|
} else {
|
||||||
|
onlineList.push_back(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
|
@ -174,11 +196,9 @@ bool p3StatusService::sendStatus(StatusInfo& statusInfo)
|
||||||
sendItem(statusItem);
|
sendItem(statusItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3StatusService::statusAvailable(){
|
bool p3StatusService::statusAvailable(){
|
||||||
return receivedItems();
|
return receivedItems();
|
||||||
}
|
}
|
||||||
|
@ -301,5 +321,18 @@ int p3StatusService::status(){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************** pqiMonitor callback ***********************/
|
||||||
|
|
||||||
|
void p3StatusService::statusChange(const std::list<pqipeer> &plist)
|
||||||
|
{
|
||||||
|
StatusInfo statusInfo;
|
||||||
|
std::list<pqipeer>::const_iterator it;
|
||||||
|
for (it = plist.begin(); it != plist.end(); it++) {
|
||||||
|
if ((it->state & RS_PEER_S_FRIEND) && (it->state & RS_PEER_CONNECTED)) {
|
||||||
|
/* send current status */
|
||||||
|
if (statusInfo.id.empty() == false || getOwnStatus(statusInfo)) {
|
||||||
|
sendStatus(it->id, statusInfo.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
* custom string.
|
* custom string.
|
||||||
* @see rsiface/rsstatus.h for status constants
|
* @see rsiface/rsstatus.h for status constants
|
||||||
*/
|
*/
|
||||||
class p3StatusService: public p3Service, public p3Config
|
class p3StatusService: public p3Service, public p3Config, public pqiMonitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -52,13 +52,18 @@ virtual ~p3StatusService();
|
||||||
virtual int tick();
|
virtual int tick();
|
||||||
virtual int status();
|
virtual int status();
|
||||||
|
|
||||||
|
/*************** pqiMonitor callback ***********************/
|
||||||
|
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||||
|
|
||||||
/********* RsStatus ***********/
|
/********* RsStatus ***********/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status is set to offline as default if no info received from relevant peer
|
* Status is set to offline as default if no info received from relevant peer
|
||||||
*/
|
*/
|
||||||
|
virtual bool getOwnStatus(StatusInfo& statusInfo);
|
||||||
virtual bool getStatus(std::list<StatusInfo>& statusInfo);
|
virtual bool getStatus(std::list<StatusInfo>& statusInfo);
|
||||||
virtual bool sendStatus(StatusInfo& statusInfo);
|
/* id = "", status is sent to all online peers */
|
||||||
|
virtual bool sendStatus(const std::string &id, uint32_t status);
|
||||||
virtual bool statusAvailable();
|
virtual bool statusAvailable();
|
||||||
|
|
||||||
/******************************/
|
/******************************/
|
||||||
|
|
|
@ -250,8 +250,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
/** StatusBar section ********/
|
/** StatusBar section ********/
|
||||||
/* initialize combobox in status bar */
|
/* initialize combobox in status bar */
|
||||||
statusComboBox = new QComboBox(statusBar());
|
statusComboBox = new QComboBox(statusBar());
|
||||||
initializeStatusObject(statusComboBox);
|
initializeStatusObject(statusComboBox, true);
|
||||||
connect(statusComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));
|
|
||||||
|
|
||||||
QWidget *widget = new QWidget();
|
QWidget *widget = new QWidget();
|
||||||
QHBoxLayout *hbox = new QHBoxLayout();
|
QHBoxLayout *hbox = new QHBoxLayout();
|
||||||
|
@ -295,7 +294,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
/* Creates a tray icon with a context menu and adds it to the system's * notification area. */
|
/* Creates a tray icon with a context menu and adds it to the system's * notification area. */
|
||||||
createTrayIcon();
|
createTrayIcon();
|
||||||
|
|
||||||
loadOwnStatus(); // hack; placed in constructor to preempt sendstatus, so status loaded from file
|
loadOwnStatus();
|
||||||
|
|
||||||
/* Set focus to the current page */
|
/* Set focus to the current page */
|
||||||
ui.stackPages->currentWidget()->setFocus();
|
ui.stackPages->currentWidget()->setFocus();
|
||||||
|
@ -356,8 +355,7 @@ void MainWindow::createTrayIcon()
|
||||||
trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
||||||
|
|
||||||
QMenu *pStatusMenu = trayMenu->addMenu(tr("Status"));
|
QMenu *pStatusMenu = trayMenu->addMenu(tr("Status"));
|
||||||
initializeStatusObject(pStatusMenu);
|
initializeStatusObject(pStatusMenu, true);
|
||||||
connect(pStatusMenu, SIGNAL(triggered (QAction*)), this, SLOT(statusChanged(QAction*)));
|
|
||||||
|
|
||||||
trayMenu->addSeparator();
|
trayMenu->addSeparator();
|
||||||
trayMenu->addAction(_messengerwindowAct);
|
trayMenu->addAction(_messengerwindowAct);
|
||||||
|
@ -830,27 +828,6 @@ void MainWindow::setStyle()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get own status */
|
|
||||||
static int getOwnStatus()
|
|
||||||
{
|
|
||||||
std::string ownId = rsPeers->getOwnId();
|
|
||||||
|
|
||||||
StatusInfo si;
|
|
||||||
std::list<StatusInfo> statusList;
|
|
||||||
std::list<StatusInfo>::iterator it;
|
|
||||||
|
|
||||||
if (!rsStatus->getStatus(statusList)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (it = statusList.begin(); it != statusList.end(); it++){
|
|
||||||
if (it->id == ownId)
|
|
||||||
return it->status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set status object to status value */
|
/* set status object to status value */
|
||||||
static void setStatusObject(QObject *pObject, int nStatus)
|
static void setStatusObject(QObject *pObject, int nStatus)
|
||||||
{
|
{
|
||||||
|
@ -888,10 +865,12 @@ void MainWindow::loadOwnStatus()
|
||||||
{
|
{
|
||||||
m_bStatusLoadDone = true;
|
m_bStatusLoadDone = true;
|
||||||
|
|
||||||
int nStatus = getOwnStatus();
|
StatusInfo statusInfo;
|
||||||
|
if (rsStatus->getOwnStatus(statusInfo)) {
|
||||||
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {
|
/* send status to all added objects */
|
||||||
setStatusObject(*it, nStatus);
|
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {
|
||||||
|
setStatusObject(*it, statusInfo.status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,8 +878,7 @@ void MainWindow::checkAndSetIdle(int idleTime)
|
||||||
{
|
{
|
||||||
if ((idleTime >= (int) maxTimeBeforeIdle) && !isIdle) {
|
if ((idleTime >= (int) maxTimeBeforeIdle) && !isIdle) {
|
||||||
setIdle(true);
|
setIdle(true);
|
||||||
}else
|
} else if ((idleTime < (int) maxTimeBeforeIdle) && isIdle) {
|
||||||
if((idleTime < (int) maxTimeBeforeIdle) && isIdle) {
|
|
||||||
setIdle(false);
|
setIdle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,13 +888,18 @@ void MainWindow::checkAndSetIdle(int idleTime)
|
||||||
void MainWindow::setIdle(bool idle)
|
void MainWindow::setIdle(bool idle)
|
||||||
{
|
{
|
||||||
isIdle = idle;
|
isIdle = idle;
|
||||||
setStatus(NULL, getOwnStatus());
|
|
||||||
|
StatusInfo statusInfo;
|
||||||
|
if (rsStatus->getOwnStatus(statusInfo)) {
|
||||||
|
setStatus(NULL, statusInfo.status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add and initialize status object */
|
/* add and initialize status object */
|
||||||
void MainWindow::initializeStatusObject(QObject *pObject)
|
void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
|
||||||
{
|
{
|
||||||
if (m_apStatusObjects.find(pObject) != m_apStatusObjects.end()) {
|
if (m_apStatusObjects.find(pObject) != m_apStatusObjects.end()) {
|
||||||
|
/* already added */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,6 +927,10 @@ void MainWindow::initializeStatusObject(QObject *pObject)
|
||||||
pAction->setCheckable(true);
|
pAction->setCheckable(true);
|
||||||
pMenu->addAction(pAction);
|
pMenu->addAction(pAction);
|
||||||
pGroup->addAction(pAction);
|
pGroup->addAction(pAction);
|
||||||
|
|
||||||
|
if (bConnect) {
|
||||||
|
connect(pMenu, SIGNAL(triggered (QAction*)), this, SLOT(statusChangedMenu(QAction*)));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* initialize combobox */
|
/* initialize combobox */
|
||||||
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
|
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
|
||||||
|
@ -951,15 +938,19 @@ void MainWindow::initializeStatusObject(QObject *pObject)
|
||||||
pComboBox->addItem(QIcon(":/images/im-user.png"), tr("Online"), RS_STATUS_ONLINE);
|
pComboBox->addItem(QIcon(":/images/im-user.png"), tr("Online"), RS_STATUS_ONLINE);
|
||||||
pComboBox->addItem(QIcon(":/images/im-user-busy.png"), tr("Busy"), RS_STATUS_BUSY);
|
pComboBox->addItem(QIcon(":/images/im-user-busy.png"), tr("Busy"), RS_STATUS_BUSY);
|
||||||
pComboBox->addItem(QIcon(":/images/im-user-away.png"), tr("Away"), RS_STATUS_AWAY);
|
pComboBox->addItem(QIcon(":/images/im-user-away.png"), tr("Away"), RS_STATUS_AWAY);
|
||||||
|
|
||||||
|
if (bConnect) {
|
||||||
|
connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* add more objects here */
|
/* add more objects here */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bStatusLoadDone) {
|
if (m_bStatusLoadDone) {
|
||||||
/* loadOwnStatus done, set own status directly */
|
/* loadOwnStatus done, set own status directly */
|
||||||
int nStatus = getOwnStatus();
|
StatusInfo statusInfo;
|
||||||
if (nStatus != -1) {
|
if (rsStatus->getOwnStatus(statusInfo)) {
|
||||||
setStatusObject(pObject, nStatus);
|
setStatusObject(pObject, statusInfo.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -968,29 +959,20 @@ void MainWindow::initializeStatusObject(QObject *pObject)
|
||||||
void MainWindow::removeStatusObject(QObject *pObject)
|
void MainWindow::removeStatusObject(QObject *pObject)
|
||||||
{
|
{
|
||||||
m_apStatusObjects.erase(pObject);
|
m_apStatusObjects.erase(pObject);
|
||||||
|
|
||||||
|
/* disconnect all signals between the object and MainWindow */
|
||||||
|
disconnect(pObject, NULL, this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Save own status Online,Away,Busy **/
|
/** Save own status Online,Away,Busy **/
|
||||||
void MainWindow::setStatus(QObject *pObject, int nStatus)
|
void MainWindow::setStatus(QObject *pObject, int nStatus)
|
||||||
{
|
{
|
||||||
RsPeerDetails detail;
|
|
||||||
std::string ownId = rsPeers->getOwnId();
|
|
||||||
|
|
||||||
if (!rsPeers->getPeerDetails(ownId, detail)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusInfo si;
|
|
||||||
|
|
||||||
if (isIdle && nStatus == (int) RS_STATUS_ONLINE) {
|
if (isIdle && nStatus == (int) RS_STATUS_ONLINE) {
|
||||||
/* set idle state only when I am in online state */
|
/* set idle only when I am online */
|
||||||
nStatus = RS_STATUS_INACTIVE;
|
nStatus = RS_STATUS_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
si.id = ownId;
|
rsStatus->sendStatus("", nStatus);
|
||||||
si.status = nStatus;
|
|
||||||
|
|
||||||
rsStatus->sendStatus(si);
|
|
||||||
|
|
||||||
/* set status in all status objects, but the calling one */
|
/* set status in all status objects, but the calling one */
|
||||||
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {
|
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {
|
||||||
|
@ -1001,7 +983,7 @@ void MainWindow::setStatus(QObject *pObject, int nStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new status from context menu */
|
/* new status from context menu */
|
||||||
void MainWindow::statusChanged(QAction *pAction)
|
void MainWindow::statusChangedMenu(QAction *pAction)
|
||||||
{
|
{
|
||||||
if (pAction == NULL) {
|
if (pAction == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -1017,5 +999,6 @@ void MainWindow::statusChangedComboBox(int index)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(statusComboBox, statusComboBox->itemData(index, Qt::UserRole).toInt());
|
/* no object known */
|
||||||
|
setStatus(NULL, statusComboBox->itemData(index, Qt::UserRole).toInt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ public:
|
||||||
static void installGroupChatNotifier();
|
static void installGroupChatNotifier();
|
||||||
|
|
||||||
/* initialize widget with status informations, status constant stored in data or in Qt::UserRole */
|
/* initialize widget with status informations, status constant stored in data or in Qt::UserRole */
|
||||||
void initializeStatusObject(QObject *pObject);
|
void initializeStatusObject(QObject *pObject, bool bConnect);
|
||||||
void removeStatusObject(QObject *pObject);
|
void removeStatusObject(QObject *pObject);
|
||||||
void setStatus(QObject *pObject, int nStatus);
|
void setStatus(QObject *pObject, int nStatus);
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ private slots:
|
||||||
void showMess();
|
void showMess();
|
||||||
void showSettings();
|
void showSettings();
|
||||||
void setStyle();
|
void setStyle();
|
||||||
void statusChanged(QAction *pAction);
|
void statusChangedMenu(QAction *pAction);
|
||||||
void statusChangedComboBox(int index);
|
void statusChangedComboBox(int index);
|
||||||
|
|
||||||
/** Called when user attempts to quit via quit button*/
|
/** Called when user attempts to quit via quit button*/
|
||||||
|
|
|
@ -163,16 +163,16 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||||
|
|
||||||
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
|
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
|
||||||
connect(ui.statuscomboBox, SIGNAL(activated(int)), this, SLOT(statusChanged(int)));
|
|
||||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateMessengerDisplay()));
|
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateMessengerDisplay()));
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateAvatar()));
|
connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateAvatar()));
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
|
connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateMessengerDisplay()));
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateMessengerDisplay()));
|
||||||
timer->start(1000); /* one second */
|
timer->setInterval(1000); /* one second */
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
|
||||||
/* to hide the header */
|
/* to hide the header */
|
||||||
ui.messengertreeWidget->header()->hide();
|
ui.messengertreeWidget->header()->hide();
|
||||||
|
@ -208,7 +208,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
|
|
||||||
MainWindow *pMainWindow = MainWindow::getInstance();
|
MainWindow *pMainWindow = MainWindow::getInstance();
|
||||||
if (pMainWindow) {
|
if (pMainWindow) {
|
||||||
pMainWindow->initializeStatusObject(ui.statuscomboBox);
|
pMainWindow->initializeStatusObject(ui.statuscomboBox, true);
|
||||||
}
|
}
|
||||||
insertPeers();
|
insertPeers();
|
||||||
updateAvatar();
|
updateAvatar();
|
||||||
|
@ -383,18 +383,19 @@ void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point )
|
||||||
|
|
||||||
void MessengerWindow::updateMessengerDisplay()
|
void MessengerWindow::updateMessengerDisplay()
|
||||||
{
|
{
|
||||||
if(RsAutoUpdatePage::eventsLocked())
|
if (RsAutoUpdatePage::eventsLocked() == false) {
|
||||||
return ;
|
|
||||||
// add self nick and Avatar to Friends.
|
// add self nick and Avatar to Friends.
|
||||||
RsPeerDetails pd ;
|
RsPeerDetails pd;
|
||||||
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
|
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
|
||||||
|
QString titleStr("<span style=\"font-size:14pt; font-weight:500;"
|
||||||
QString titleStr("<span style=\"font-size:14pt; font-weight:500;"
|
"color:#FFFFFF;\">%1</span>");
|
||||||
"color:#FFFFFF;\">%1</span>");
|
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" - ") + QString::fromStdString(pd.location)));
|
||||||
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" - ") + QString::fromStdString(pd.location))) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
insertPeers();
|
insertPeers();
|
||||||
|
}
|
||||||
|
|
||||||
|
timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the list of peers from the RsIface. */
|
/* get the list of peers from the RsIface. */
|
||||||
|
@ -1008,21 +1009,7 @@ void MessengerWindow::loadmystatusmessage()
|
||||||
/** Save own status message */
|
/** Save own status message */
|
||||||
void MessengerWindow::savestatusmessage()
|
void MessengerWindow::savestatusmessage()
|
||||||
{
|
{
|
||||||
Settings->setValueToGroup("Profile", "StatusMessage",ui.messagelineEdit->text());
|
rsMsgs->setCustomStateString(ui.messagelineEdit->text().toStdString());
|
||||||
|
|
||||||
rsMsgs->setCustomStateString(ui.messagelineEdit->text().toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessengerWindow::statusChanged(int index)
|
|
||||||
{
|
|
||||||
if (index < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow *pMainWindow = MainWindow::getInstance();
|
|
||||||
if (pMainWindow) {
|
|
||||||
pMainWindow->setStatus(ui.statuscomboBox, ui.statuscomboBox->itemData(index, Qt::UserRole).toInt());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessengerWindow::on_actionSort_Peers_Descending_Order_activated()
|
void MessengerWindow::on_actionSort_Peers_Descending_Order_activated()
|
||||||
|
|
|
@ -88,7 +88,6 @@ private slots:
|
||||||
|
|
||||||
void changeAvatarClicked();
|
void changeAvatarClicked();
|
||||||
|
|
||||||
void statusChanged(int index);
|
|
||||||
void savestatusmessage();
|
void savestatusmessage();
|
||||||
|
|
||||||
void on_actionSort_Peers_Descending_Order_activated();
|
void on_actionSort_Peers_Descending_Order_activated();
|
||||||
|
@ -110,6 +109,7 @@ private:
|
||||||
|
|
||||||
/* Worker Functions */
|
/* Worker Functions */
|
||||||
/* (1) Update Display */
|
/* (1) Update Display */
|
||||||
|
QTimer *timer;
|
||||||
|
|
||||||
/* (2) Utility Fns */
|
/* (2) Utility Fns */
|
||||||
QTreeWidgetItem *getCurrentPeer();
|
QTreeWidgetItem *getCurrentPeer();
|
||||||
|
|
|
@ -1578,8 +1578,7 @@ void PeersDialog::on_actionCreate_New_Channel_activated()
|
||||||
/** Loads own personal status */
|
/** Loads own personal status */
|
||||||
void PeersDialog::loadmypersonalstatus()
|
void PeersDialog::loadmypersonalstatus()
|
||||||
{
|
{
|
||||||
|
ui.mypersonalstatuslabel->setText(QString::fromStdString(rsMsgs->getCustomStateString()));
|
||||||
ui.mypersonalstatuslabel->setText(QString::fromStdString(rsMsgs->getCustomStateString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeersDialog::statusmessage()
|
void PeersDialog::statusmessage()
|
||||||
|
|
|
@ -9,10 +9,12 @@ RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
|
||||||
: MainPage(parent)
|
: MainPage(parent)
|
||||||
{
|
{
|
||||||
_timer = new QTimer ;
|
_timer = new QTimer ;
|
||||||
|
_timer->setInterval(ms_update_period);
|
||||||
|
_timer->setSingleShot(true);
|
||||||
|
|
||||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate())) ;
|
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate())) ;
|
||||||
|
|
||||||
_timer->start(ms_update_period) ;
|
_timer->start() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsAutoUpdatePage::showEvent(QShowEvent *event)
|
void RsAutoUpdatePage::showEvent(QShowEvent *event)
|
||||||
|
@ -26,11 +28,12 @@ void RsAutoUpdatePage::timerUpdate()
|
||||||
{
|
{
|
||||||
// only update when the widget is visible.
|
// only update when the widget is visible.
|
||||||
//
|
//
|
||||||
if(_locked || !isVisible())
|
if(_locked == false && isVisible()) {
|
||||||
return ;
|
updateDisplay();
|
||||||
|
update() ; // Qt flush
|
||||||
updateDisplay();
|
}
|
||||||
update() ; // Qt flush
|
|
||||||
|
_timer->start() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsAutoUpdatePage::lockAllEvents() { _locked = true ; }
|
void RsAutoUpdatePage::lockAllEvents() { _locked = true ; }
|
||||||
|
|
|
@ -52,27 +52,19 @@ StatusMessage::~StatusMessage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusMessage::closeEvent (QCloseEvent * event)
|
|
||||||
{
|
|
||||||
QDialog::closeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Saves the changes on this page */
|
/** Saves the changes on this page */
|
||||||
void StatusMessage::save()
|
void StatusMessage::save()
|
||||||
{
|
{
|
||||||
Settings->setValueToGroup("Profile", "StatusMessage",ui.txt_StatusMessage->text());
|
rsMsgs->setCustomStateString(ui.txt_StatusMessage->text().toStdString());
|
||||||
|
|
||||||
rsMsgs->setCustomStateString(ui.txt_StatusMessage->text().toStdString());
|
close();
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Loads the settings for this page */
|
/** Loads the settings for this page */
|
||||||
void StatusMessage::load()
|
void StatusMessage::load()
|
||||||
{
|
{
|
||||||
ui.txt_StatusMessage->setText(QString::fromStdString(rsMsgs->getCustomStateString()));
|
ui.txt_StatusMessage->setText(QString::fromStdString(rsMsgs->getCustomStateString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,23 +31,19 @@ class StatusMessage : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
StatusMessage(QWidget *parent = 0, Qt::WFlags flags = 0);
|
StatusMessage(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
~StatusMessage();
|
~StatusMessage();
|
||||||
|
|
||||||
protected:
|
|
||||||
void closeEvent (QCloseEvent * event);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
/** Saves the changes on this page */
|
/** Saves the changes on this page */
|
||||||
void save();
|
void save();
|
||||||
/** Loads the settings for this page */
|
/** Loads the settings for this page */
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::StatusMessage ui;
|
Ui::StatusMessage ui;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue