about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c77
1 files changed, 44 insertions, 33 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index e4717bff..1a55765e 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -3125,46 +3125,57 @@ gboolean
 cmd_tiny(gchar **args, struct cmd_help_t help)
 {
     char *url = args[0];
-    win_type_t win_type = ui_current_win_type();
+    ProfWin *current = wins_get_current();
+
+    if (current->type != WIN_CHAT && current->type != WIN_MUC && current->type != WIN_PRIVATE) {
+        cons_show("/tiny can only be used in chat windows");
+        return TRUE;
+    }
 
     if (!tinyurl_valid(url)) {
-        GString *error = g_string_new("/tiny, badly formed URL: ");
-        g_string_append(error, url);
-        cons_show_error(error->str);
-        if (win_type != WIN_CONSOLE) {
-            ui_current_error_line(error->str);
-        }
-        g_string_free(error, TRUE);
-    } else if (win_type != WIN_CONSOLE) {
-        char *tiny = tinyurl_get(url);
+        win_vprint(current, '-', NULL, 0, THEME_ERROR, "", "/tiny, badly formed URL: %s", url);
+        return TRUE;
+    }
 
-        if (tiny != NULL) {
-            if (win_type == WIN_CHAT) {
-                ProfChatWin *chatwin = wins_get_current_chat();
+    char *tiny = tinyurl_get(url);
+    if (!tiny) {
+        win_print(current, '-', NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl.");
+        return TRUE;
+    }
+
+    switch (current->type){
+    case WIN_CHAT:
+    {
+        ProfChatWin *chatwin = wins_get_current_chat();
 #ifdef HAVE_LIBOTR
-                if (otr_is_secure(chatwin->barejid)) {
-                    _send_otr_chat_message(chatwin->barejid, tiny);
-                } else {
-                    _send_chat_message(chatwin->barejid, tiny);
-                }
-#else
-                _send_chat_message(chatwin->barejid, tiny);
-#endif
-            } else if (win_type == WIN_PRIVATE) {
-                ProfPrivateWin *privatewin = wins_get_current_private();
-                message_send_private(privatewin->fulljid, tiny);
-                ui_outgoing_private_msg(privatewin->fulljid, tiny);
-            } else if (win_type == WIN_MUC) {
-                ProfMucWin *mucwin = wins_get_current_muc();
-                message_send_groupchat(mucwin->roomjid, tiny);
-            }
-            free(tiny);
+        if (otr_is_secure(chatwin->barejid)) {
+            _send_otr_chat_message(chatwin->barejid, tiny);
         } else {
-            cons_show_error("Couldn't get tinyurl.");
+            _send_chat_message(chatwin->barejid, tiny);
         }
-    } else {
-        cons_show("/tiny can only be used in chat windows");
+#else
+        _send_chat_message(chatwin->barejid, tiny);
+#endif
+        break;
     }
+    case WIN_PRIVATE:
+    {
+        ProfPrivateWin *privatewin = wins_get_current_private();
+        message_send_private(privatewin->fulljid, tiny);
+        ui_outgoing_private_msg(privatewin->fulljid, tiny);
+        break;
+    }
+    case WIN_MUC:
+    {
+        ProfMucWin *mucwin = wins_get_current_muc();
+        message_send_groupchat(mucwin->roomjid, tiny);
+        break;
+    }
+    default:
+        break;
+    }
+
+    free(tiny);
 
     return TRUE;
 }
mit/074console.mu?h=hlt&id=77d5b5d658830bd24724f945e0d6ddf6a06adc0e'>77d5b5d6 ^
45c08fea ^
502d2ea5 ^




e3092e7b ^

45c08fea ^
77d5b5d6 ^
45c08fea ^
e3092e7b ^
502d2ea5 ^


e3092e7b ^
502d2ea5 ^


45c08fea ^
502d2ea5 ^
e3092e7b ^
502d2ea5 ^


e3092e7b ^
6aa42628 ^
45c08fea ^
502d2ea5 ^
e3092e7b ^

c6c19a27 ^


45c08fea ^
77d5b5d6 ^
45c08fea ^
502d2ea5 ^





e3092e7b ^
f8c0ef3e ^

77d5b5d6 ^
45c08fea ^
f8c0ef3e ^


502d2ea5 ^





f8c0ef3e ^

502d2ea5 ^
f8c0ef3e ^
6a0f71b9 ^

77d5b5d6 ^
6a0f71b9 ^

502d2ea5 ^

6a0f71b9 ^
502d2ea5 ^
6a0f71b9 ^
5e9eff8c ^


77d5b5d6 ^
5e9eff8c ^

502d2ea5 ^
5e9eff8c ^
bc643692 ^
5e9eff8c ^

502d2ea5 ^
5e9eff8c ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113