diff options
author | nomad <gmc_holle@users.sourceforge.net> | 2009-03-02 01:31:22 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-03-02 01:31:22 +0300 |
commit | 7bd80f87d0f3ba6f56ca40ebc031a5edef40c521 (patch) | |
tree | 7eb7c956095c458a4cb659895de442999ed19f2c /src | |
parent | 0b8cf50a1241138928300c6f127e6e304a2496e7 (diff) |
Adding channel descriptions
Diffstat (limited to 'src')
-rw-r--r-- | src/Channel.cpp | 7 | ||||
-rw-r--r-- | src/Channel.h | 5 | ||||
-rw-r--r-- | src/Message.cpp | 14 | ||||
-rw-r--r-- | src/Message.h | 15 | ||||
-rw-r--r-- | src/mumble/MainWindow.cpp | 32 | ||||
-rw-r--r-- | src/mumble/MainWindow.h | 2 | ||||
-rw-r--r-- | src/mumble/MainWindow.ui | 11 | ||||
-rw-r--r-- | src/mumble/Messages.cpp | 5 | ||||
-rw-r--r-- | src/murmur/DBus.cpp | 2 | ||||
-rw-r--r-- | src/murmur/Messages.cpp | 28 | ||||
-rw-r--r-- | src/murmur/Server.cpp | 46 | ||||
-rw-r--r-- | src/murmur/Server.h | 5 | ||||
-rw-r--r-- | src/murmur/ServerDB.cpp | 35 |
13 files changed, 184 insertions, 23 deletions
diff --git a/src/Channel.cpp b/src/Channel.cpp index 94fc4bcae..d03379708 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -40,9 +40,10 @@ uint qHash(const Channel::qpPlayerLink & pl) { return qHash(pl.first) + qHash(pl.second); } -Channel::Channel(int id, QString name, QObject *p) : QObject(p) { +Channel::Channel(int id, QString name, QString desc, QObject *p) : QObject(p) { iId = id; qsName = name; + qsDesc = desc; bInheritACL = true; cParent = qobject_cast<Channel *>(p); if (cParent) @@ -72,13 +73,13 @@ Channel *Channel::get(int id) { return c_qhChannels.value(id); } -Channel *Channel::add(int id, QString name, QObject *po) { +Channel *Channel::add(int id, QString name, QString desc, QObject *po) { QWriteLocker lock(&c_qrwlChannels); if (c_qhChannels.contains(id)) return NULL; - Channel *c = new Channel(id,name, po); + Channel *c = new Channel(id,name, desc, po); c_qhChannels.insert(id, c); return c; } diff --git a/src/Channel.h b/src/Channel.h index e5791d85d..c9ce58654 100644 --- a/src/Channel.h +++ b/src/Channel.h @@ -47,6 +47,7 @@ class Channel : public QObject { int iId; Channel *cParent; QString qsName; + QString qsDesc; QList<Channel *> qlChannels; QList<Player *> qlPlayers; QHash<QString, Group *> qhGroups; @@ -63,11 +64,11 @@ class Channel : public QObject { static QHash<int, Channel *> c_qhChannels; static QReadWriteLock c_qrwlChannels; - Channel(int id, QString name, QObject *p = NULL); + Channel(int id, QString name, QString desc, QObject *p = NULL); ~Channel(); static Channel *get(int); - static Channel *add(int, QString, QObject *p = NULL); + static Channel *add(int, QString, QString, QObject *p = NULL); static void remove(Channel *); void addChannel(Channel *c); diff --git a/src/Message.cpp b/src/Message.cpp index 5a935abad..bd31b68a8 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -136,6 +136,9 @@ Message *Message::networkToMessage(PacketDataStream &qdsIn) { case ChannelRename: mMsg = new MessageChannelRename(); break; + case ChannelDescUpdate: + mMsg = new MessageChannelDescUpdate(); + break; case TextMessage: mMsg = new MessageTextMessage(); break; @@ -252,6 +255,9 @@ void MessageHandler::dispatch(Connection *cCon, Message *msg) { case Message::ChannelRename: msgChannelRename(cCon, static_cast<MessageChannelRename *>(msg)); break; + case Message::ChannelDescUpdate: + msgChannelDescUpdate(cCon, static_cast<MessageChannelDescUpdate *>(msg)); + break; case Message::TextMessage: msgTextMessage(cCon, static_cast<MessageTextMessage *>(msg)); break; @@ -517,6 +523,14 @@ void MessageChannelRename::restoreStream(PacketDataStream &qdsIn) { qdsIn >> iId >> qsName; } +void MessageChannelDescUpdate::saveStream(PacketDataStream &qdsOut) const { + qdsOut << iId << qsDesc; +} + +void MessageChannelDescUpdate::restoreStream(PacketDataStream &qdsIn) { + qdsIn >> iId >> qsDesc; +} + void MessageTextMessage::saveStream(PacketDataStream &qdsOut) const { qdsOut << uiVictim; qdsOut << iChannel; diff --git a/src/Message.h b/src/Message.h index 7e2835375..303cf59f8 100644 --- a/src/Message.h +++ b/src/Message.h @@ -43,7 +43,7 @@ class Message { virtual void saveStream(PacketDataStream &) const; virtual void restoreStream(PacketDataStream &); public: - enum MessageType { ServerReject, ServerAuthenticate, Speex, ServerSync, ServerJoin, ServerLeave, ServerBanList, PlayerMute, PlayerDeaf, PlayerKick, PlayerRename, PlayerBan, PlayerMove, PlayerSelfMuteDeaf, ChannelAdd, ChannelRemove, ChannelMove, ChannelLink, ChannelRename, PermissionDenied, EditACL, QueryUsers, Ping, TextMessage, PlayerTexture, CryptSetup, CryptSync, PingStats, ContextAction, ContextAddAction }; + enum MessageType { ServerReject, ServerAuthenticate, Speex, ServerSync, ServerJoin, ServerLeave, ServerBanList, PlayerMute, PlayerDeaf, PlayerKick, PlayerRename, PlayerBan, PlayerMove, PlayerSelfMuteDeaf, ChannelAdd, ChannelRemove, ChannelMove, ChannelLink, ChannelRename, PermissionDenied, EditACL, QueryUsers, Ping, TextMessage, PlayerTexture, CryptSetup, CryptSync, PingStats, ContextAction, ContextAddAction, ChannelDescUpdate }; unsigned int uiSession; Message(); @@ -309,6 +309,18 @@ class MessageChannelRename : public Message { }; }; +class MessageChannelDescUpdate : public Message { + protected: + void saveStream(PacketDataStream &) const; + void restoreStream(PacketDataStream &); + public: + int iId; + QString qsDesc; + Message::MessageType messageType() const { + return ChannelDescUpdate; + }; +}; + class MessageServerBanList : public Message { protected: void saveStream(PacketDataStream &) const; @@ -486,6 +498,7 @@ class MessageHandler { virtual void msgChannelMove(Connection *, MessageChannelMove *) = 0; virtual void msgChannelLink(Connection *, MessageChannelLink *) = 0; virtual void msgChannelRename(Connection *, MessageChannelRename *) = 0; + virtual void msgChannelDescUpdate(Connection *, MessageChannelDescUpdate *) = 0; virtual void msgServerBanList(Connection *, MessageServerBanList *) = 0; virtual void msgTextMessage(Connection *, MessageTextMessage *) = 0; virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *) = 0; diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index ec2346ec6..ab483c90d 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -819,6 +819,7 @@ void MainWindow::on_qmChannel_aboutToShow() { qmChannel->addAction(qaChannelRemove); qmChannel->addAction(qaChannelACL); qmChannel->addAction(qaChannelRename); + qmChannel->addAction(qaChannelDescUpdate); qmChannel->addSeparator(); qmChannel->addAction(qaChannelLink); qmChannel->addAction(qaChannelUnlink); @@ -841,13 +842,14 @@ void MainWindow::on_qmChannel_aboutToShow() { qmChannel->addAction(a); } - bool add, remove, acl, rename, link, unlink, unlinkall, msg; - add = remove = acl = rename = link = unlink = unlinkall = msg = false; + bool add, remove, acl, rename, descUpdate, link, unlink, unlinkall, msg; + add = remove = acl = rename = descUpdate = link = unlink = unlinkall = msg = false; if (g.uiSession != 0) { add = true; acl = true; msg = true; + descUpdate = true; Channel *c = pmModel->getChannel(idx); Channel *home = ClientPlayer::get(g.uiSession)->cChannel; @@ -871,6 +873,7 @@ void MainWindow::on_qmChannel_aboutToShow() { qaChannelRemove->setEnabled(remove); qaChannelACL->setEnabled(acl); qaChannelRename->setEnabled(rename); + qaChannelDescUpdate->setEnabled(descUpdate); qaChannelLink->setEnabled(link); qaChannelUnlink->setEnabled(unlink); qaChannelUnlinkAll->setEnabled(unlinkall); @@ -939,6 +942,31 @@ void MainWindow::on_qaChannelRename_triggered() { } } +void MainWindow::on_qaChannelDescUpdate_triggered() { + bool ok; + Channel *c = pmModel->getChannel(qtvPlayers->currentIndex()); + if (! c) + return; + + int id = c->iId; + + TextMessage tm; + tm.setWindowTitle(tr("Change description of channel %1").arg(c->qsName)); + tm.qteEdit->setText(c->qsDesc); + int res = tm.exec(); + + c = Channel::get(id); + if (!c) + return; + + if (res==QDialog::Accepted) { + MessageChannelDescUpdate mcdu; + mcdu.iId = id; + mcdu.qsDesc = tm.message(); + g.sh->sendMessage(&mcdu); + } +} + void MainWindow::on_qaChannelACL_triggered() { Channel *c = pmModel->getChannel(qtvPlayers->currentIndex()); int id = c ? c->iId : 0; diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 904b2f052..87973cc4b 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -133,6 +133,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin void on_qaChannelRemove_triggered(); void on_qaChannelACL_triggered(); void on_qaChannelRename_triggered(); + void on_qaChannelDescUpdate_triggered(); void on_qaChannelLink_triggered(); void on_qaChannelUnlink_triggered(); void on_qaChannelUnlinkAll_triggered(); @@ -197,6 +198,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin virtual void msgChannelMove(Connection *, MessageChannelMove *); virtual void msgChannelLink(Connection *, MessageChannelLink *); virtual void msgChannelRename(Connection *, MessageChannelRename *); + virtual void msgChannelDescUpdate(Connection *, MessageChannelDescUpdate *); virtual void msgServerBanList(Connection *, MessageServerBanList *); virtual void msgTextMessage(Connection *, MessageTextMessage *); virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *); diff --git a/src/mumble/MainWindow.ui b/src/mumble/MainWindow.ui index 3da8f3ba4..b34d02929 100644 --- a/src/mumble/MainWindow.ui +++ b/src/mumble/MainWindow.ui @@ -303,6 +303,17 @@ <string>This renames a channel.</string> </property> </action> + <action name="qaChannelDescUpdate" > + <property name="text" > + <string>&Changed Channel Description</string> + </property> + <property name="toolTip" > + <string>Changes the channel description</string> + </property> + <property name="whatsThis" > + <string>This changes the description of a channel.</string> + </property> + </action> <action name="qaChannelLink" > <property name="text" > <string>&Link</string> diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 668fc5fdf..86ae5d8cc 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -280,6 +280,11 @@ void MainWindow::msgChannelRename(Connection *, MessageChannelRename *msg) { pmModel->renameChannel(c, msg->qsName); } +void MainWindow::msgChannelDescUpdate(Connection *, MessageChannelDescUpdate *msg) { + Channel *c = Channel::get(msg->iId); + if (c) c->qsDesc=msg->qsDesc; +} + void MainWindow::msgChannelLink(Connection *, MessageChannelLink *msg) { Channel *c = Channel::get(msg->iId); if (!c) diff --git a/src/murmur/DBus.cpp b/src/murmur/DBus.cpp index 0f4ded712..0f4d2e37a 100644 --- a/src/murmur/DBus.cpp +++ b/src/murmur/DBus.cpp @@ -433,7 +433,7 @@ void MurmurDBus::sendMessageChannel(int id, bool tree, const QString &text, cons void MurmurDBus::addChannel(const QString &name, int chanparent, const QDBusMessage &msg, int &newid) { CHANNEL_SETUP_VAR(chanparent); - Channel *nc = server->addChannel(cChannel, name); + Channel *nc = server->addChannel(cChannel, name, QString()); server->updateChannel(nc); newid = nc->iId; diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index 3ed1444ee..1394ca6d9 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -178,6 +178,13 @@ void Server::msgServerAuthenticate(Connection *cCon, MessageServerAuthenticate * sendMessage(cCon, &mca); + MessageChannelDescUpdate mcdu; + + mcdu.iId = c->iId; + mcdu.qsDesc = c->qsDesc; + + sendMessage(static_cast<User *>(p), &mcdu); + foreach(c, c->qlChannels) q.enqueue(c); } @@ -454,7 +461,7 @@ void Server::msgChannelAdd(Connection *cCon, MessageChannelAdd *msg) { } } - Channel *c = addChannel(p, msg->qsName); + Channel *c = addChannel(p, msg->qsName, QString()); if (uSource->iId >= 0) { Group *g = new Group(c, "admin"); g->qsAdd << uSource->iId; @@ -523,6 +530,25 @@ void Server::msgChannelRename(Connection *cCon, MessageChannelRename *msg) { emit channelStateChanged(c); } +void Server::msgChannelDescUpdate(Connection *cCon, MessageChannelDescUpdate *msg) { + MSG_SETUP(Player::Authenticated); + Channel *c = qhChannels.value(msg->iId); + + if (!c) + return; + + if (! hasPermission(uSource, c, ChanACL::Write)) { + PERM_DENIED(uSource, c, ChanACL::Write); + return; + } + + log(uSource, QString("Changed description for channel %1 to: %2").arg(*c).arg(msg->qsDesc)); + c->qsDesc = msg->qsDesc; + updateChannel(c); + sendAll(msg); + sendChannelDescriptionUpdate(c); +} + void Server::msgChannelMove(Connection *cCon, MessageChannelMove *msg) { MSG_SETUP(Player::Authenticated); diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 9905c9bcb..1c6f08ee5 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -124,7 +124,7 @@ Server::Server(int snum, QObject *p) : QThread(p) { #ifdef Q_OS_UNIX int val = 0xe0; if (setsockopt(sUdpSocket, IPPROTO_IP, IP_TOS, &val, sizeof(val))) { - int val = 0x80; + val = 0x80; if (setsockopt(sUdpSocket, IPPROTO_IP, IP_TOS, &val, sizeof(val))) log("Server: Failed to set TOS for UDP Socket"); } @@ -738,6 +738,35 @@ void Server::sendExcept(Message *mMsg, Connection *cCon) { u->sendMessage(mMsg); } +void Server::sendChannelDescription(Player *p, Channel *c) { + // To be backwards compatible to clients prior or equal to version 1.1.7 + // we will send a server message to each one + QString desc; + + desc="<br /><u>"; + desc.append(c->qsName); + desc.append(":</u><br /><br />"); + desc.append(c->qsDesc); + + sendTextMessage(NULL, static_cast<User*>(p), false, desc); +} + +void Server::sendChannelDescriptionUpdate(Channel *changed, Channel *current) { + if (current==NULL) { + qWarning() << "Itering changed channel " << changed->qsName; + current=changed; + } else qWarning() << "Itering sub-channel " << current->qsName; + + foreach(Player *siblingPlayer, current->qlPlayers) { + qWarning() << "Itering player " << siblingPlayer->qsName; + sendChannelDescription(siblingPlayer, changed); + } + + foreach(Channel *siblingChannel, current->qlChannels) { + if (siblingChannel->qsDesc.isEmpty()) sendChannelDescriptionUpdate(changed, siblingChannel); + } +} + void Server::removeChannel(Channel *chan, Player *src, Channel *dest) { Channel *c; Player *p; @@ -785,11 +814,26 @@ void Server::playerEnterChannel(Player *p, Channel *c, bool quiet) { if (quiet && (p->cChannel == c)) return; + // Get old and new channel of user + // Lookup first channel in list of parent channels of new and old one + // which has a channel description + Channel *oldChannel=p->cChannel; + Channel *newChannel=c; + + while (oldChannel && oldChannel->qsDesc.isEmpty()) oldChannel=oldChannel->cParent; + while (newChannel && newChannel->qsDesc.isEmpty()) newChannel=newChannel->cParent; + { QWriteLocker wl(&qrwlUsers); c->addPlayer(p); } + // Only send message with channel description if it changed + // That means the channel has its own description or it does not + // share the same first parent channel which has one with the channel + // the user came from + if (newChannel && newChannel!=oldChannel) sendChannelDescription(p, newChannel); + if (quiet) return; diff --git a/src/murmur/Server.h b/src/murmur/Server.h index faedf1f18..ef48dde31 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -205,6 +205,8 @@ class Server : public QThread, public MessageHandler { void sendAll(Message *); void sendExcept(Message *, Connection *); void sendMessage(Connection *, Message *); + void sendChannelDescription(Player *, Channel *); + void sendChannelDescriptionUpdate(Channel *changed, Channel *current=NULL); void setLiveConf(const QString &key, const QString &value); @@ -256,7 +258,7 @@ class Server : public QThread, public MessageHandler { void initialize(); typedef QPair<quint32, int> qpBan; int authenticate(QString &name, const QString &pw); - Channel *addChannel(Channel *c, const QString &name); + Channel *addChannel(Channel *c, const QString &name, const QString &desc = QString()); void removeChannel(const Channel *c); void readChannels(Channel *p = NULL); void readLinks(); @@ -306,6 +308,7 @@ class Server : public QThread, public MessageHandler { virtual void msgChannelMove(Connection *, MessageChannelMove *); virtual void msgChannelLink(Connection *, MessageChannelLink *); virtual void msgChannelRename(Connection *, MessageChannelRename *); + virtual void msgChannelDescUpdate(Connection *, MessageChannelDescUpdate *); virtual void msgServerBanList(Connection *, MessageServerBanList *); virtual void msgTextMessage(Connection *, MessageTextMessage *); virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *); diff --git a/src/murmur/ServerDB.cpp b/src/murmur/ServerDB.cpp index c1468a56c..3ccf84571 100644 --- a/src/murmur/ServerDB.cpp +++ b/src/murmur/ServerDB.cpp @@ -169,7 +169,7 @@ ServerDB::ServerDB() { SQLDO("CREATE UNIQUE INDEX %1config_key ON %1config(server_id, keystring)"); SQLDO("CREATE TRIGGER %1config_server_del AFTER DELETE ON %1servers FOR EACH ROW BEGIN DELETE FROM %1config WHERE server_id = old.server_id; END;"); - SQLDO("CREATE TABLE %1channels (server_id INTEGER NOT NULL, channel_id INTEGER NOT NULL, parent_id INTEGER, name TEXT, inheritacl INTEGER)"); + SQLDO("CREATE TABLE %1channels (server_id INTEGER NOT NULL, channel_id INTEGER NOT NULL, parent_id INTEGER, name TEXT, inheritacl INTEGER, description TEXT)"); SQLDO("CREATE UNIQUE INDEX %1channel_id ON %1channels(server_id, channel_id)"); SQLDO("CREATE TRIGGER %1channels_parent_del AFTER DELETE ON %1channels FOR EACH ROW BEGIN DELETE FROM %1channels WHERE parent_id = old.channel_id AND server_id = old.server_id; UPDATE %1players SET lastchannel=0 WHERE lastchannel = old.channel_id AND server_id = old.server_id; END;"); SQLDO("CREATE TRIGGER %1channels_server_del AFTER DELETE ON %1servers FOR EACH ROW BEGIN DELETE FROM %1channels WHERE server_id = old.server_id; END;"); @@ -205,7 +205,7 @@ ServerDB::ServerDB() { SQLDO("CREATE TRIGGER %1bans_del_server AFTER DELETE ON %1servers FOR EACH ROW BEGIN DELETE FROM %1bans WHERE server_id = old.server_id; END;"); SQLDO("INSERT INTO %1servers (server_id) VALUES(1)"); - SQLDO("INSERT INTO %1meta (keystring, value) VALUES('version','2')"); + SQLDO("INSERT INTO %1meta (keystring, value) VALUES('version','3')"); SQLDO("VACUUM"); } else { @@ -220,7 +220,7 @@ ServerDB::ServerDB() { SQLDO("CREATE UNIQUE INDEX %1config_key ON %1config(server_id, keystring)"); SQLDO("ALTER TABLE %1config ADD CONSTRAINT %1config_server_del FOREIGN KEY (server_id) REFERENCES %1servers(server_id) ON DELETE CASCADE"); - SQLDO("CREATE TABLE %1channels (server_id INTEGER NOT NULL, channel_id INTEGER NOT NULL, parent_id INTEGER, name varchar(255), inheritacl INTEGER) Type=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); + SQLDO("CREATE TABLE %1channels (server_id INTEGER NOT NULL, channel_id INTEGER NOT NULL, parent_id INTEGER, name varchar(255), inheritacl INTEGER, description TEXT) Type=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); SQLDO("CREATE UNIQUE INDEX %1channel_id ON %1channels(server_id, channel_id)"); SQLDO("ALTER TABLE %1channels ADD CONSTRAINT %1channels_parent_del FOREIGN KEY (server_id, parent_id) REFERENCES %1channels(server_id,channel_id) ON DELETE CASCADE"); SQLDO("ALTER TABLE %1channels ADD CONSTRAINT %1channels_server_del FOREIGN KEY (server_id) REFERENCES %1servers(server_id) ON DELETE CASCADE"); @@ -258,7 +258,7 @@ ServerDB::ServerDB() { SQLDO("ALTER TABLE %1bans ADD CONSTRAINT %1bans_del_server FOREIGN KEY(server_id) REFERENCES %1servers(server_id) ON DELETE CASCADE"); SQLDO("INSERT INTO %1servers (server_id) VALUES(1)"); - SQLDO("INSERT INTO %1meta (keystring, value) VALUES('version','2')"); + SQLDO("INSERT INTO %1meta (keystring, value) VALUES('version','3')"); } if (migrate) { @@ -288,6 +288,7 @@ ServerDB::ServerDB() { SQLDO("UPDATE %1meta SET value='2' WHERE keystring='version'"); SQLDO("CREATE UNIQUE INDEX %1players_id ON %1players (server_id, player_id)"); + SQLDO("ALTER TABLE %1channels ADD COLUMN description TEXT"); } else { SQLDO("CREATE TABLE %1slog(server_id INTEGER, msg TEXT, msgtime TIMESTAMP) Type=InnoDB"); SQLDO("CREATE INDEX %1slog_time ON %1slog(msgtime)"); @@ -306,6 +307,15 @@ ServerDB::ServerDB() { SQLDO("ALTER TABLE %1players CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"); SQLDO("ALTER TABLE %1servers CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"); SQLDO("ALTER TABLE %1slog CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"); + SQLDO("ALTER TABLE %1channels ADD COLUMN description TEXT"); + } + } else if (version < 3) { + if (Meta::mp.qsDBDriver == "QSQLITE") { + SQLDO("UPDATE %1meta SET value='3' WHERE keystring='version'"); + SQLDO("ALTER TABLE %1channels ADD COLUMN description TEXT"); + } else { + SQLDO("UPDATE %1meta SET value='3' WHERE keystring='version'"); + SQLDO("ALTER TABLE %1channels ADD COLUMN description TEXT"); } } query.clear(); @@ -879,7 +889,7 @@ void Server::removeLink(Channel *c, Channel *l) { } } -Channel *Server::addChannel(Channel *p, const QString &name) { +Channel *Server::addChannel(Channel *p, const QString &name, const QString &desc) { TransactionHolder th; QSqlQuery &query = *th.qsqQuery; @@ -892,13 +902,14 @@ Channel *Server::addChannel(Channel *p, const QString &name) { id = query.value(0).toInt(); - SQLPREP("INSERT INTO %1channels (server_id, parent_id, channel_id, name) VALUES (?,?,?,?)"); + SQLPREP("INSERT INTO %1channels (server_id, parent_id, channel_id, name, description) VALUES (?,?,?,?,?)"); query.addBindValue(iServerNum); query.addBindValue(p->iId); query.addBindValue(id); query.addBindValue(name); + query.addBindValue(desc); SQLEXEC(); - Channel *c = new Channel(id, name, p); + Channel *c = new Channel(id, name, desc, p); qhChannels.insert(id, c); return c; } @@ -920,10 +931,11 @@ void Server::updateChannel(const Channel *c) { ChanACL *acl; QSqlQuery &query = *th.qsqQuery; - SQLPREP("UPDATE %1channels SET name = ?, parent_id = ?, inheritacl = ? WHERE server_id = ? AND channel_id = ?"); + SQLPREP("UPDATE %1channels SET name = ?, parent_id = ?, inheritacl = ?, description = ? WHERE server_id = ? AND channel_id = ?"); query.addBindValue(c->qsName); query.addBindValue(c->cParent ? c->cParent->iId : QVariant()); query.addBindValue(c->bInheritACL ? 1 : 0); + query.addBindValue(c->qsDesc); query.addBindValue(iServerNum); query.addBindValue(c->iId); SQLEXEC(); @@ -1045,17 +1057,17 @@ void Server::readChannels(Channel *p) { { TransactionHolder th; if (parentid == -1) { - SQLPREP("SELECT channel_id, name, inheritacl FROM %1channels WHERE server_id = ? AND parent_id IS NULL ORDER BY name"); + SQLPREP("SELECT channel_id, name, inheritacl, description FROM %1channels WHERE server_id = ? AND parent_id IS NULL ORDER BY name"); query.addBindValue(iServerNum); } else { - SQLPREP("SELECT channel_id, name, inheritacl FROM %1channels WHERE server_id = ? AND parent_id=? ORDER BY name"); + SQLPREP("SELECT channel_id, name, inheritacl, description FROM %1channels WHERE server_id = ? AND parent_id=? ORDER BY name"); query.addBindValue(iServerNum); query.addBindValue(parentid); } SQLEXEC(); while (query.next()) { - c = new Channel(query.value(0).toInt(), query.value(1).toString(), p); + c = new Channel(query.value(0).toInt(), query.value(1).toString(), query.value(3).toString(), p); if (! p) c->setParent(this); qhChannels.insert(c->iId, c); @@ -1134,6 +1146,7 @@ void Server::dumpChannel(const Channel *c) { } qWarning("Channel %s (ACLInherit %d)", qPrintable(c->qsName), c->bInheritACL); + qWarning("Description: %s", qPrintable(c->qsDesc)); foreach(g, c->qhGroups) { qWarning("Group %s (Inh %d Able %d)", qPrintable(g->qsName), g->bInherit, g->bInheritable); foreach(pid, g->qsAdd) |