[ekg2-commit] ekg2: commands.c (HEAD) jabber.c (HEAD) jabber_handlers.c (HEAD) misc.c (HEAD) [peres]
CVS commit
cvs w toxygen.net
Czw, 3 Maj 2007, 21:30:19 CEST
Module name: ekg2
Changes by: peres 2007-05-03 21:30:16
Modified files:
commands.c jabber.c jabber_handlers.c misc.c
Log message:
- subject sending rewrite & fix,
- missing conversation-connected variables,
- linearizing & chomping subject in incoming messages
(GTalk server likes to add \n after the subject),
- fixing subject support in conversations
(i.e. now I know why that hadn't been there).
Index: commands.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/jabber/commands.c,v
diff -d -u -r1.163 -r1.164
--- commands.c 3 May 2007 18:29:48 -0000 1.163
+++ commands.c 3 May 2007 19:30:15 -0000 1.164
@@ -513,24 +513,8 @@
}
if (!(uid = jid_target2uid(session, target, quiet)))
return -1;
- /* czy wiadomość ma mieć temat? */
- if (!j->istlen && config_subject_prefix && !xstrncmp(params[1], config_subject_prefix, subjectlen)) {
- char *subtmp = xstrdup((params[1]+subjectlen)); /* obcinamy prefix tematu */
- char *tmp;
- /* jeśli ma więcej linijek, zostawiamu tylko pierwszą */
- if ((tmp = xstrchr(subtmp, 10)))
- *tmp = 0;
-
- subject = jabber_escape(subtmp);
- /* body of wiadomość to wszystko po końcu pierwszej linijki */
- msg = (tmp) ? (tmp+1) : NULL;
- xfree(subtmp);
- } else
- msg = params[1]; /* bez tematu */
- if ((c = newconference_find(session, target)))
- ismuc = 1;
-
+ /* threaded messages */
if (!xstrcasecmp(name, "tmsg")) {
/* just make it compatible with /msg */
thread = params[1];
@@ -545,6 +529,24 @@
xfree(tmp);
}
+ /* message subject, TheNewBetterWay^TM */
+ if (!j->istlen && config_subject_prefix && !xstrncmp(params[1], config_subject_prefix, subjectlen)) {
+ char *last = xstrchr(params[1]+subjectlen, 10);
+
+ if (last) {
+ *last = 0;
+ subject = jabber_escape(params[1]+subjectlen);
+ *last = 10;
+ msg = last+1;
+ } else {
+ subject = jabber_escape(params[1]+subjectlen);
+ msg = NULL;
+ }
+ } else
+ msg = params[1]; /* bez tematu */
+ if ((c = newconference_find(session, target)))
+ ismuc = 1;
+
if (j->send_watch) j->send_watch->transfer_limit = -1;
if (ismuc)
Index: jabber.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/jabber/jabber.c,v
diff -d -u -r1.330 -r1.331
--- jabber.c 3 May 2007 16:34:30 -0000 1.330
+++ jabber.c 3 May 2007 19:30:16 -0000 1.331
@@ -1443,6 +1443,7 @@
static plugins_params_t jabber_plugin_vars[] = {
PLUGIN_VAR_ADD("alias", SESSION_VAR_ALIAS, VAR_STR, 0, 0, NULL),
+ PLUGIN_VAR_ADD("allow_add_reply_id", 0, VAR_INT, "1", 0, NULL),
/* '666' enabled for everyone (DON'T TRY IT!); '0' - disabled; '1' - enabled for the same id (allow from diffrent resources); '2' - enabled for allow_remote_control_jids (XXX) */
PLUGIN_VAR_ADD("allow_remote_control", 0, VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("auto_auth", 0, VAR_INT, "0", 0, NULL),
@@ -1463,6 +1464,7 @@
PLUGIN_VAR_ADD("gpg_key", 0, VAR_STR, NULL, 0, jabber_gpg_changed),
PLUGIN_VAR_ADD("gpg_password", 0, VAR_STR, NULL, 1, jabber_gpg_changed),
PLUGIN_VAR_ADD("log_formats", SESSION_VAR_LOG_FORMATS, VAR_STR, "xml,simple", 0, NULL),
+ PLUGIN_VAR_ADD("msg_gen_thread", 0, VAR_BOOL, "0", 0, NULL),
PLUGIN_VAR_ADD("password", SESSION_VAR_PASSWORD, VAR_STR, "foo", 1, NULL),
PLUGIN_VAR_ADD("plaintext_passwd", 0, VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("ping-server", 0, VAR_BOOL, "0", 0, NULL),
Index: jabber_handlers.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/jabber/jabber_handlers.c,v
diff -d -u -r1.105 -r1.106
--- jabber_handlers.c 3 May 2007 16:34:30 -0000 1.105
+++ jabber_handlers.c 3 May 2007 19:30:16 -0000 1.106
@@ -1013,7 +1013,16 @@
const char *type = jabber_attr(n->atts, "type");
int class = (!xstrcmp(type, "chat") || !xstrcmp(type, "groupchat") ? EKG_MSGCLASS_CHAT : EKG_MSGCLASS_MESSAGE);
const int nonthreaded = (!nthread || !nthread->data);
+ const int hassubject = (nsubject && nsubject->data);
+ if (hassubject) { /* we need to linearize this earlier */
+ char *tmp = nsubject->data;
+
+ if (tmp+xstrlen(tmp) == '\n') /* chomp */
+ *tmp = '\0';
+ while ((tmp = xstrchr(tmp, '\n')))
+ *tmp = ' ';
+ }
if ((class == EKG_MSGCLASS_MESSAGE) /* conversations only with messages */
&& (!nonthreaded /* either if we've got thread */
|| ((nbody || nsubject) && (session_int_get(s, "allow_add_reply_id") > 1))
@@ -1021,7 +1030,7 @@
)) {
jabber_conversation_t *thr;
int i = jabber_conversation_find(j, uid,
- (nonthreaded && nsubject && nsubject->data ? nsubject->data : NULL),
+ (nonthreaded && hassubject ? nsubject->data : NULL),
(nonthreaded ? NULL : nthread->data),
&thr, (session_int_get(s, "allow_add_reply_id") > 0));
@@ -1047,12 +1056,8 @@
thr->subject = xstrdup(nsubject->data); /* we should store newest message subject, not first */
}
}
- if (nsubject && nsubject->data) {
- char *tmp;
-
+ if (hassubject) {
string_append(body, "Subject: ");
- if ((tmp = xstrchr(nsubject->data, 10))) /* XXX, think about it */
- *tmp = 0;
string_append(body, nsubject->data);
if (nthread && nthread->data) {
string_append(body, " [");
Index: misc.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/jabber/misc.c,v
diff -d -u -r1.52 -r1.53
--- misc.c 3 May 2007 16:34:31 -0000 1.52
+++ misc.c 3 May 2007 19:30:16 -0000 1.53
@@ -533,7 +533,8 @@
thr = xmalloc(sizeof(jabber_conversation_t));
thr->thread = xstrdup(thread);
thr->uid = xstrdup(uid);
- thr->subject = xstrdup(resubject ? resubject : subject); /* XXX, why I haven't added this earlier? */
+ /* IMPORTANT: thr->subject is maintained by message handler
+ * Now I know why I haven't added it earlier here */
if (prev)
prev->next = thr;
else
Więcej informacji o liście dyskusyjnej ekg2-commit