about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_defs.c24
-rw-r--r--src/command/cmd_funcs.c51
-rw-r--r--src/command/cmd_funcs.h1
3 files changed, 76 insertions, 0 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 24d4a737..db42be1c 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2411,6 +2411,30 @@ static struct cmd_t command_defs[] = {
               "/color own off")
     },
 
+    { "/stamp",
+      parse_args, 0, 2, NULL,
+      CMD_NOSUBFUNCS
+      CMD_MAINFUNC(cmd_stamp)
+      CMD_TAGS(
+              CMD_TAG_UI)
+      CMD_SYN(
+              "/stamp outgoing <string>",
+              "/stamp incoming <string>",
+              "/stamp unset outgoing|incoming")
+      CMD_DESC(
+              "Set chat window stamp values. "
+              "Current format of single log-line in the chat window next: \"<timestamp> <encryption sign> <stamp> <message>\" "
+              "where <stamp> is \"me:\" for incoming messages or \"username@server/resource\" for outcoming messages. "
+              "This command allows to change <stamp> value.")
+      CMD_ARGS(
+              { "outgoing", "Set outgoing messages stamp" },
+              { "incoming", "Set incoming stamp"},
+              { "unset outgoing|incoming", "unset stamp"})
+      CMD_EXAMPLES(
+              "/stamp outgoing -->",
+              "/stamp incoming <--")
+    },
+
     { "/avatar",
       parse_args, 2, 2, NULL,
       CMD_NOSUBFUNCS
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 685369c4..39fc087a 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -9020,6 +9020,57 @@ cmd_paste(ProfWin* window, const char* const command, gchar** args)
 }
 
 gboolean
+cmd_stamp(ProfWin* window, const char* const command, gchar** args)
+{
+    if (g_strv_length(args) == 0) {
+        char* def = prefs_get_string(PREF_OUTGOING_STR);
+        if (def) {
+            cons_show("The outgoing stamp is: %s", def);
+            free(def);
+        } else {
+            cons_show("No outgoing stamp.");
+        }
+        def = prefs_get_string(PREF_INCOMING_STR);
+        if (def) {
+            cons_show("The incoming stamp is: %s", def);
+            free(def);
+        } else {
+            cons_show("No incoming stamp.");
+        }
+        return TRUE;
+    }
+
+    if (g_strv_length(args) == 1) {
+        cons_show("Wrong usage: need a parameter.");
+        return TRUE;
+    }
+
+    if (g_strv_length(args) == 2) {
+        if (g_strcmp0(args[0], "outgoing") == 0) {
+            prefs_set_string(PREF_OUTGOING_STR, args[1]);
+            cons_show("Outgoing stamp set to: %s", args[1]);
+        } else if (g_strcmp0(args[0], "incoming") == 0) {
+            prefs_set_string(PREF_INCOMING_STR, args[1]);
+            cons_show("Incoming stamp set to: %s", args[1]);
+        } else if (g_strcmp0(args[0], "unset") == 0) {
+            if (g_strcmp0(args[1], "incoming") == 0) {
+                prefs_set_string(PREF_INCOMING_STR, NULL);
+                cons_show("Incoming stamp unset");
+            } else if (g_strcmp0(args[1], "outgoing") == 0) {
+                prefs_set_string(PREF_OUTGOING_STR, NULL);
+                cons_show("Outgoing stamp unset");
+            } else {
+                cons_bad_cmd_usage(command);
+            }
+        } else {
+            cons_bad_cmd_usage(command);
+        }
+    }
+
+    return TRUE;
+}
+
+gboolean
 cmd_color(ProfWin* window, const char* const command, gchar** args)
 {
     if (g_strcmp0(args[0], "on") == 0) {
diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h
index f4cbe0bf..41074720 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -250,5 +250,6 @@ gboolean cmd_correct_editor(ProfWin* window, const char* const command, gchar**
 gboolean cmd_silence(ProfWin* window, const char* const command, gchar** args);
 gboolean cmd_register(ProfWin* window, const char* const command, gchar** args);
 gboolean cmd_mood(ProfWin* window, const char* const command, gchar** args);
+gboolean cmd_stamp(ProfWin* window, const char* const command, gchar** args);
 
 #endif