client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
--- a/QTfrontend/net/newnetclient.cpp Sun Sep 09 19:57:13 2012 +0400
+++ b/QTfrontend/net/newnetclient.cpp Sun Sep 09 20:11:07 2012 +0200
@@ -357,6 +357,7 @@
QString flags = lst[1];
bool setFlag = flags[0] == '+';
+ const QStringList nicks = lst.mid(2);
while(flags.size() > 1)
{
@@ -366,18 +367,29 @@
switch(c)
{
case 'r':
- {
- for(int i = 2; i < lst.size(); ++i)
- {
- if (lst[i] == mynick)
+ foreach (const QString & nick, nicks)
{
- if (isChief && !setFlag) ToggleReady();
- else emit setMyReadyStatus(setFlag);
+ if (nick == mynick)
+ {
+ if (isChief && !setFlag) ToggleReady();
+ else emit setMyReadyStatus(setFlag);
+ }
+ emit setReadyStatus(nick, setFlag);
}
+ break;
- emit setReadyStatus(lst[i], setFlag);
- }
- }
+ case 'a':
+ foreach (const QString & nick, nicks)
+ {
+ if (nick == mynick)
+ emit adminAccess(setFlag);
+
+ emit setAdminStatus(nick, setFlag);
+ }
+ break;
+
+ default:
+ qWarning() << "Net: Unknown client-flag: " << c;
}
}
@@ -503,7 +515,7 @@
if (lst[0] == "ADMIN_ACCESS")
{
- emit adminAccess(true);
+ // obsolete, see +a client flag
return;
}
--- a/QTfrontend/net/newnetclient.h Sun Sep 09 19:57:13 2012 +0400
+++ b/QTfrontend/net/newnetclient.h Sun Sep 09 20:11:07 2012 +0200
@@ -139,6 +139,7 @@
void setReadyStatus(const QString & nick, bool isReady);
void setMyReadyStatus(bool isReady);
+ void setAdminStatus(const QString & nick, bool isReady);
public slots:
void ToggleReady();