Added generic notification ui. Notify the user when roster query fails.
git-svn-id: http://voip.null.ro/svn/yate@4042 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
bfaed13943
commit
9be5e60682
|
@ -411,6 +411,9 @@ enum PrivateNotifAction {
|
|||
PrivNotificationLogin,
|
||||
PrivNotificationAccEdit,
|
||||
PrivNotificationAccounts,
|
||||
PrivNotification1,
|
||||
PrivNotification2,
|
||||
PrivNotification3,
|
||||
};
|
||||
static const TokenDict s_notifPrefix[] = {
|
||||
{"messages_ok:", PrivNotificationOk},
|
||||
|
@ -418,6 +421,9 @@ static const TokenDict s_notifPrefix[] = {
|
|||
{"messages_login:", PrivNotificationLogin},
|
||||
{"messages_acc_edit:", PrivNotificationAccEdit},
|
||||
{"messages_accounts:", PrivNotificationAccounts},
|
||||
{"messages_1:", PrivNotification1},
|
||||
{"messages_2:", PrivNotification2},
|
||||
{"messages_3:", PrivNotification3},
|
||||
{0,0,}
|
||||
};
|
||||
enum ChatLogEnum {
|
||||
|
@ -1311,6 +1317,9 @@ static void addAccPendingStatus(NamedList& p, ClientAccount* acc, AccountStatus*
|
|||
p.addParam("status",stat->text(),false);
|
||||
}
|
||||
|
||||
// Forward declaration needed in setAccountStatus()
|
||||
void removeAccNotifications(ClientAccount* acc);
|
||||
|
||||
// Set account status from global. Update UI. Notify remote party
|
||||
// Use current status if none specified
|
||||
static void setAccountStatus(ClientAccountList* accounts, ClientAccount* acc,
|
||||
|
@ -1381,6 +1390,8 @@ static void setAccountStatus(ClientAccountList* accounts, ClientAccount* acc,
|
|||
acc->resource().m_status = ClientResource::Offline;
|
||||
// Avoid notification when disconnected
|
||||
acc->m_params.setParam("internal.nologinfail",String::boolText(true));
|
||||
// Remove account notifications now
|
||||
removeAccNotifications(acc);
|
||||
}
|
||||
acc->resource().setStatusText();
|
||||
}
|
||||
|
@ -1714,6 +1725,24 @@ static NamedList* buildNotifArea(NamedList& list, const char* itemType, const St
|
|||
return upd;
|
||||
}
|
||||
|
||||
// Show/hide a button in generic notification. Set its title also
|
||||
static inline void setGenericNotif(NamedList& list, int index, const char* title)
|
||||
{
|
||||
String name;
|
||||
name << "messages_" << index;
|
||||
list.addParam("show:" + name,String::boolText(!TelEngine::null(title)));
|
||||
list.addParam(name,title);
|
||||
}
|
||||
|
||||
// Customize buttons in generic notification
|
||||
static void setGenericNotif(NamedList& list, const char* title1 = 0,
|
||||
const char* title2 = 0, const char* title3 = 0)
|
||||
{
|
||||
setGenericNotif(list,1,title1);
|
||||
setGenericNotif(list,2,title2);
|
||||
setGenericNotif(list,3,title3);
|
||||
}
|
||||
|
||||
// Remove a notification area account/contact item
|
||||
static inline void removeNotifArea(const char* itemType, const String& account,
|
||||
const String& contact = String::empty(), Window* wnd = 0)
|
||||
|
@ -1723,6 +1752,16 @@ static inline void removeNotifArea(const char* itemType, const String& account,
|
|||
Client::self()->delTableRow("messages",id,wnd);
|
||||
}
|
||||
|
||||
// Remove all notifications belonging to an account
|
||||
static void removeAccNotifications(ClientAccount* acc)
|
||||
{
|
||||
if (!acc)
|
||||
return;
|
||||
const String& account = acc->toString();
|
||||
removeNotifArea("loginfail",account);
|
||||
removeNotifArea("rosterreqfail",account);
|
||||
}
|
||||
|
||||
// Show a contact's info window
|
||||
// Update it and, optionally, activate it
|
||||
static bool updateContactInfo(ClientContact* c, bool create = false, bool activate = false)
|
||||
|
@ -2255,6 +2294,16 @@ static void updateTelAccList(bool ok, ClientAccount* acc)
|
|||
Client::self()->delTableRow(s_account,acc->toString());
|
||||
}
|
||||
|
||||
// Query roster on a given account
|
||||
static bool queryRoster(ClientAccount* acc)
|
||||
{
|
||||
if (!acc)
|
||||
return false;
|
||||
Message* m = Client::buildMessage("user.roster",acc->toString(),"query");
|
||||
m->copyParams(acc->params(),"protocol");
|
||||
return Engine::enqueue(m);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ClientWizard
|
||||
|
@ -4607,7 +4656,7 @@ bool DefaultLogic::delAccount(const String& account, Window* wnd)
|
|||
// Disconnect
|
||||
Engine::enqueue(userLogin(acc,false));
|
||||
// Delete from memory and UI. Save the accounts file
|
||||
removeNotifArea("loginfail",account);
|
||||
removeAccNotifications(acc);
|
||||
Window* w = getAccPasswordWnd(account,false);
|
||||
if (w)
|
||||
Client::self()->closeWindow(w->toString());
|
||||
|
@ -5212,6 +5261,8 @@ bool DefaultLogic::handleUserNotify(Message& msg, bool& stopLogic)
|
|||
ClientAccount* acc = m_accounts->findAccount(account);
|
||||
if (!acc)
|
||||
return false;
|
||||
// Always remove roster request notification when account status changed
|
||||
removeNotifArea("rosterreqfail",account);
|
||||
// Notify status
|
||||
String txt = reg ? "Registered" : "Unregistered";
|
||||
txt << " account " << account;
|
||||
|
@ -5338,9 +5389,7 @@ bool DefaultLogic::handleUserNotify(Message& msg, bool& stopLogic)
|
|||
Message* m = Client::buildNotify(true,acc->toString(),
|
||||
acc->resource(false));
|
||||
Engine::enqueue(m);
|
||||
m = Client::buildMessage("user.roster",acc->toString(),"query");
|
||||
m->copyParams(acc->params(),"protocol");
|
||||
Engine::enqueue(m);
|
||||
queryRoster(acc);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -5357,21 +5406,48 @@ bool DefaultLogic::handleUserRoster(Message& msg, bool& stopLogic)
|
|||
const String& oper = msg["operation"];
|
||||
if (!oper)
|
||||
return false;
|
||||
bool fail = false;
|
||||
bool remove = (oper != "update");
|
||||
if (remove && oper != "delete")
|
||||
return false;
|
||||
if (remove && oper != "delete") {
|
||||
if (oper != "queryerror")
|
||||
return false;
|
||||
fail = true;
|
||||
}
|
||||
// Postpone message processing
|
||||
if (Client::self()->postpone(msg,Client::UserRoster)) {
|
||||
stopLogic = true;
|
||||
return false;
|
||||
}
|
||||
int n = msg.getIntValue("contact.count");
|
||||
if (n < 1)
|
||||
if (n < 1 && !fail)
|
||||
return false;
|
||||
const String& account = msg["account"];
|
||||
ClientAccount* a = account ? m_accounts->findAccount(account) : 0;
|
||||
if (!a)
|
||||
return false;
|
||||
if (fail) {
|
||||
String reason = msg["error"];
|
||||
if (reason) {
|
||||
const String& res = msg["reason"];
|
||||
if (res)
|
||||
reason << " (" << res << ")";
|
||||
}
|
||||
else
|
||||
reason = msg["reason"];
|
||||
NamedList list("");
|
||||
NamedList* upd = buildNotifArea(list,"rosterreqfail",account,
|
||||
String::empty(),"Friends list failure");
|
||||
setGenericNotif(*upd,"Retry");
|
||||
String text;
|
||||
text << "Failed to retrieve the friends list";
|
||||
text.append(reason,": ");
|
||||
text.append(account,"\r\nAccount: ");
|
||||
upd->addParam("text",text);
|
||||
showNotificationArea(true,Client::self()->getWindow(s_wndMain),&list);
|
||||
return false;
|
||||
}
|
||||
if (msg.getBoolValue("queryrsp"))
|
||||
removeNotifArea("rosterreqfail",account);
|
||||
ObjList removed;
|
||||
NamedList chatlist("");
|
||||
for (int i = 1; i <= n; i++) {
|
||||
|
@ -7658,6 +7734,10 @@ bool DefaultLogic::handleNotificationAreaAction(const String& action, Window* wn
|
|||
}
|
||||
}
|
||||
}
|
||||
if (type == "rosterreqfail") {
|
||||
if (act->value == PrivNotification1)
|
||||
remove = queryRoster(m_accounts->findAccount(account));
|
||||
}
|
||||
else
|
||||
return false;
|
||||
if (handled) {
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
<ui version="4.0" >
|
||||
<class>messages_generic</class>
|
||||
<widget class="QWidget" name="messages_generic" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="text" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet" >
|
||||
<string>QTextEdit {
|
||||
background: transparent;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="tabChangesFocus" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="topMargin" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="messages_3" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="_yate_identity" stdset="0" >
|
||||
<string>messages_3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="messages_2" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="_yate_identity" stdset="0" >
|
||||
<string>messages_2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="messages_1" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="_yate_identity" stdset="0" >
|
||||
<string>messages_1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="messages_close" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="_yate_identity" stdset="0" >
|
||||
<string>deleteselecteditem:messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -115,6 +115,10 @@ description=contactinfo.ui
|
|||
enabled=no
|
||||
description=messages_header.ui
|
||||
|
||||
[messages_generic]
|
||||
enabled=no
|
||||
description=messages_generic.ui
|
||||
|
||||
[messages_okrejignore]
|
||||
enabled=no
|
||||
description=messages_okrejignore.ui
|
||||
|
|
|
@ -1978,6 +1978,7 @@ QTextEdit {
|
|||
<string>property:_yate_itemui=loginfail:messages_loginfail.ui</string>
|
||||
<string>property:_yate_itemui=incomingcall:messages_okrejignore.ui</string>
|
||||
<string>property:_yate_itemui=incomingfile:messages_okrejignore.ui</string>
|
||||
<string>property:_yate_itemui=rosterreqfail:messages_generic.ui</string>
|
||||
</stringlist>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue