comparison mcabber/src/screen.c @ 1602:f4a2c6f767d1

Message Receipts support (XEP-0184)
author franky
date Wed, 24 Sep 2008 11:41:29 +0200
parents dcd5d4c75199
children d0a0d96ed5d5
comparison
equal deleted inserted replaced
1601:3efc92a48945 1602:f4a2c6f767d1
157 GSList *keyseqlist; 157 GSList *keyseqlist;
158 static void add_keyseq(char *seqstr, guint mkeycode, gint value); 158 static void add_keyseq(char *seqstr, guint mkeycode, gint value);
159 159
160 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, 160 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp,
161 unsigned int prefix_flags, int force_show, 161 unsigned int prefix_flags, int force_show,
162 unsigned mucnicklen); 162 unsigned mucnicklen, gpointer xep184);
163 163
164 void scr_WriteMessage(const char *bjid, const char *text, 164 void scr_WriteMessage(const char *bjid, const char *text,
165 time_t timestamp, guint prefix_flags, 165 time_t timestamp, guint prefix_flags,
166 unsigned mucnicklen, gpointer xep184); 166 unsigned mucnicklen, gpointer xep184);
167 167
907 907
908 if (Curses) { 908 if (Curses) {
909 wprintw(logWnd, "\n%s", buffer_locale); 909 wprintw(logWnd, "\n%s", buffer_locale);
910 update_panels(); 910 update_panels();
911 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, 911 scr_WriteInWindow(NULL, buf_specialwindow, timestamp,
912 HBB_PREFIX_SPECIAL, FALSE, 0); 912 HBB_PREFIX_SPECIAL, FALSE, 0, NULL);
913 } else { 913 } else {
914 printf("%s\n", buffer_locale); 914 printf("%s\n", buffer_locale);
915 // ncurses are not initialized yet, so we call directly hbuf routine 915 // ncurses are not initialized yet, so we call directly hbuf routine
916 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, 916 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp,
917 HBB_PREFIX_SPECIAL, 0, 0, 0); 917 HBB_PREFIX_SPECIAL, 0, 0, 0, NULL);
918 } 918 }
919 919
920 g_free(convbuf1); 920 g_free(convbuf1);
921 g_free(convbuf2); 921 g_free(convbuf2);
922 g_free(buffer); 922 g_free(buffer);
1036 cryptflag = 'O'; 1036 cryptflag = 'O';
1037 else 1037 else
1038 cryptflag = '='; 1038 cryptflag = '=';
1039 g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag); 1039 g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag);
1040 } else if (line->flags & HBB_PREFIX_OUT) { 1040 } else if (line->flags & HBB_PREFIX_OUT) {
1041 char cryptflag; 1041 char cryptflag, receiptflag;
1042 if (line->flags & HBB_PREFIX_PGPCRYPT) 1042 if (line->flags & HBB_PREFIX_PGPCRYPT)
1043 cryptflag = '~'; 1043 cryptflag = '~';
1044 else if (line->flags & HBB_PREFIX_OTRCRYPT) 1044 else if (line->flags & HBB_PREFIX_OTRCRYPT)
1045 cryptflag = 'O'; 1045 cryptflag = 'O';
1046 else 1046 else
1047 cryptflag = '-'; 1047 cryptflag = '-';
1048 g_snprintf(pref, preflen, "%s-%c> ", date, cryptflag); 1048 if (line->flags & HBB_PREFIX_RECEIPT)
1049 receiptflag = 'r';
1050 else
1051 receiptflag = '-';
1052 g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag);
1049 } else if (line->flags & HBB_PREFIX_SPECIAL) { 1053 } else if (line->flags & HBB_PREFIX_SPECIAL) {
1050 strftime(date, 30, getspectprefix(), localtime(&line->timestamp)); 1054 strftime(date, 30, getspectprefix(), localtime(&line->timestamp));
1051 g_snprintf(pref, preflen, "%s ", date); 1055 g_snprintf(pref, preflen, "%s ", date);
1052 } else { 1056 } else {
1053 g_snprintf(pref, preflen, "%s ", date); 1057 g_snprintf(pref, preflen, "%s ", date);
1293 // Use winId == NULL for the special status buffer. 1297 // Use winId == NULL for the special status buffer.
1294 // Lines are splitted when they are too long to fit in the chat window. 1298 // Lines are splitted when they are too long to fit in the chat window.
1295 // If this window doesn't exist, it is created. 1299 // If this window doesn't exist, it is created.
1296 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, 1300 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp,
1297 unsigned int prefix_flags, int force_show, 1301 unsigned int prefix_flags, int force_show,
1298 unsigned mucnicklen) 1302 unsigned mucnicklen, gpointer xep184)
1299 { 1303 {
1300 winbuf *win_entry; 1304 winbuf *win_entry;
1301 char *text_locale; 1305 char *text_locale;
1302 int dont_show = FALSE; 1306 int dont_show = FALSE;
1303 int special; 1307 int special;
1340 g_free(nicklocaltmp); 1344 g_free(nicklocaltmp);
1341 g_free(nicktmp); 1345 g_free(nicktmp);
1342 } 1346 }
1343 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, 1347 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags,
1344 maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, 1348 maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks,
1345 mucnicklen); 1349 mucnicklen, xep184);
1346 g_free(text_locale); 1350 g_free(text_locale);
1347 1351
1348 if (win_entry->bd->cleared) { 1352 if (win_entry->bd->cleared) {
1349 win_entry->bd->cleared = FALSE; 1353 win_entry->bd->cleared = FALSE;
1350 if (g_list_next(win_entry->bd->top)) 1354 if (g_list_next(win_entry->bd->top))
2051 } 2055 }
2052 #endif 2056 #endif
2053 2057
2054 void scr_WriteMessage(const char *bjid, const char *text, 2058 void scr_WriteMessage(const char *bjid, const char *text,
2055 time_t timestamp, guint prefix_flags, 2059 time_t timestamp, guint prefix_flags,
2056 unsigned mucnicklen) 2060 unsigned mucnicklen, gpointer xep184)
2057 { 2061 {
2058 char *xtext; 2062 char *xtext;
2059 2063
2060 if (!timestamp) timestamp = time(NULL); 2064 if (!timestamp) timestamp = time(NULL);
2061 2065
2062 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars 2066 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars
2063 2067
2064 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen); 2068 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen,
2069 xep184);
2065 2070
2066 if (xtext != (char*)text) 2071 if (xtext != (char*)text)
2067 g_free(xtext); 2072 g_free(xtext);
2068 } 2073 }
2069 2074
2078 2083
2079 #ifdef HAVE_GLIB_REGEX 2084 #ifdef HAVE_GLIB_REGEX
2080 if (url_regex) 2085 if (url_regex)
2081 scr_LogUrls(text); 2086 scr_LogUrls(text);
2082 #endif 2087 #endif
2083 scr_WriteMessage(jidfrom, text, timestamp, prefix, mucnicklen); 2088 scr_WriteMessage(jidfrom, text, timestamp, prefix, mucnicklen, NULL);
2084 } 2089 }
2085 2090
2086 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix) 2091 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix,
2092 gpointer xep184)
2087 { 2093 {
2088 GSList *roster_elt; 2094 GSList *roster_elt;
2089 roster_elt = roster_find(jidto, jidsearch, 2095 roster_elt = roster_find(jidto, jidsearch,
2090 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); 2096 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM);
2091 2097
2092 scr_WriteMessage(jidto, text, 2098 scr_WriteMessage(jidto, text,
2093 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0); 2099 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0, xep184);
2094 2100
2095 // Show jidto's buffer unless the buddy is not in the buddylist 2101 // Show jidto's buffer unless the buddy is not in the buddylist
2096 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) 2102 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1)
2097 scr_ShowWindow(jidto, FALSE); 2103 scr_ShowWindow(jidto, FALSE);
2104 }
2105
2106 void scr_RemoveReceiptFlag(const char *bjid, gpointer xep184)
2107 {
2108 winbuf *win_entry = scr_SearchWindow(bjid, FALSE);
2109 if (win_entry) {
2110 hbuf_remove_receipt(win_entry->bd->hbuf, xep184);
2111 if (chatmode && (buddy_search_jid(bjid) == current_buddy))
2112 scr_UpdateBuddyWindow();
2113 }
2098 } 2114 }
2099 2115
2100 static inline void set_autoaway(bool setaway) 2116 static inline void set_autoaway(bool setaway)
2101 { 2117 {
2102 static enum imstatus oldstatus; 2118 static enum imstatus oldstatus;