[polari] room: Add set_topic() method and use it to implement /topic



commit d7f94c8cb4c71dee0a304b66edb8975dd53474c2
Author: Florian Müllner <florian muellner gmail com>
Date:   Tue Jul 23 01:16:01 2013 +0200

    room: Add set_topic() method and use it to implement /topic

 src/ircParser.js      |    9 ++++++++-
 src/lib/polari-room.c |   11 +++++++++++
 src/lib/polari-room.h |    2 ++
 3 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/ircParser.js b/src/ircParser.js
index df54850..088cc7b 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -21,7 +21,6 @@ const knownCommands = {
     NOTICE: _("/NOTICE <nick|channel> <message> - sends notice to <nick|channel>"),
     OP: _("/OP <nick> - gives channel operator status to <nick>"),
     QUERY: _("</QUERY <nick> - opens a private conversation with <nick>"),
-    TOPIC: _("/TOPIC <topic> - sets the topic to <topic>, or shows the current one"),
     WHOIS: _("/WHOIS <nick> - requests information on <nick>"),
     */
 
@@ -33,6 +32,7 @@ const knownCommands = {
     PART: _("/PART [<channel>] [<reason>] - leaves <channel>, by default the current one"),
     QUIT: _("</QUIT [<reason>] - disconnects from the current server"),
     SAY: _("</SAY <text> - sends <text> to the current room/contact"),
+    TOPIC: _("/TOPIC <topic> - sets the topic to <topic>, or shows the current one"),
 };
 const UNKNOWN_COMMAND_MESSAGE =
     _("Unknown command - try /HELP for a list of available commands");
@@ -204,6 +204,13 @@ const IrcParser = new Lang.Class({
                 this._sendMessage(message);
                 break;
             }
+            case 'TOPIC': {
+                if (argv.length)
+                    this._room.set_topic(stripCommand(text));
+                else
+                    output = this._createFeedbackLabel(this._room.topic || _("No topic set"));
+                break;
+            }
             default:
                 output = this._createFeedbackLabel(UNKNOWN_COMMAND_MESSAGE);
                 break;
diff --git a/src/lib/polari-room.c b/src/lib/polari-room.c
index 82d6f2d..8589e49 100644
--- a/src/lib/polari-room.c
+++ b/src/lib/polari-room.c
@@ -100,6 +100,17 @@ polari_room_should_highlight_message (PolariRoom *room,
   return result;
 }
 
+void
+polari_room_set_topic (PolariRoom *room,
+                       const char *topic)
+{
+  g_return_if_fail (POLARI_IS_ROOM (room));
+
+  tp_cli_channel_interface_subject_call_set_subject (room->priv->channel, -1,
+      topic, NULL, NULL, NULL, G_OBJECT (room));
+
+}
+
 int
 polari_room_compare (PolariRoom *room,
                      PolariRoom *other)
diff --git a/src/lib/polari-room.h b/src/lib/polari-room.h
index 053ec73..057ce49 100644
--- a/src/lib/polari-room.h
+++ b/src/lib/polari-room.h
@@ -51,6 +51,8 @@ GType polari_room_get_type (void) G_GNUC_CONST;
 gboolean polari_room_should_highlight_message (PolariRoom *room,
                                                TpMessage *message);
 
+void  polari_room_set_topic (PolariRoom *room, const char *topic);
+
 int   polari_room_compare (PolariRoom *room, PolariRoom *other);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]