Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/xmpp.c @ 1689:b8f9481dd0fe
Get server name from jid for block_unsubscribed
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Sat, 06 Feb 2010 01:12:46 +0200 |
parents | 51481414ca65 |
children | b2e0083891cc |
comparison
equal
deleted
inserted
replaced
1688:51481414ca65 | 1689:b8f9481dd0fe |
---|---|
1057 static void gotmessage(LmMessageSubType type, const char *from, | 1057 static void gotmessage(LmMessageSubType type, const char *from, |
1058 const char *body, const char *enc, const char *subject, | 1058 const char *body, const char *enc, const char *subject, |
1059 time_t timestamp, LmMessageNode *node_signed) | 1059 time_t timestamp, LmMessageNode *node_signed) |
1060 { | 1060 { |
1061 char *bjid; | 1061 char *bjid; |
1062 const char *rname, *s; | 1062 const char *rname; |
1063 char *decrypted_pgp = NULL; | 1063 char *decrypted_pgp = NULL; |
1064 char *decrypted_otr = NULL; | 1064 char *decrypted_otr = NULL; |
1065 int otr_msg = 0, free_msg = 0; | 1065 int otr_msg = 0, free_msg = 0; |
1066 | 1066 |
1067 bjid = jidtodisp(from); | 1067 bjid = jidtodisp(from); |
1124 } | 1124 } |
1125 | 1125 |
1126 // We don't call the message_in hook if 'block_unsubscribed' is true and | 1126 // We don't call the message_in hook if 'block_unsubscribed' is true and |
1127 // this is a regular message from an unsubscribed user. | 1127 // this is a regular message from an unsubscribed user. |
1128 // System messages (from our server) are allowed. | 1128 // System messages (from our server) are allowed. |
1129 if ((!settings_opt_get_int("block_unsubscribed") || | 1129 if (settings_opt_get_int("block_unsubscribed") && |
1130 (roster_getsubscription(bjid) & sub_from) || | 1130 !(roster_getsubscription(bjid) & sub_from) && |
1131 (type == LM_MESSAGE_SUB_TYPE_GROUPCHAT)) || | 1131 (type != LM_MESSAGE_SUB_TYPE_GROUPCHAT)) { |
1132 ((s = settings_opt_get("server")) != NULL && !strcasecmp(bjid, s))) { | 1132 char *sbjid = jidtodisp(lm_connection_get_jid(lconnection)); |
1133 const char *server = strchr(sbjid, JID_DOMAIN_SEPARATOR); | |
1134 if (g_strcmp0(server, bjid)) { | |
1135 scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", bjid); | |
1136 g_free(sbjid); | |
1137 goto gotmessage_return; | |
1138 } | |
1139 g_free(sbjid); | |
1140 } | |
1141 | |
1142 { // format and pass message for further processing | |
1133 gchar *fullbody = NULL; | 1143 gchar *fullbody = NULL; |
1134 guint encrypted; | 1144 guint encrypted; |
1135 | 1145 |
1136 if (decrypted_pgp) | 1146 if (decrypted_pgp) |
1137 encrypted = ENCRYPTED_PGP; | 1147 encrypted = ENCRYPTED_PGP; |
1147 fullbody = g_strdup_printf("[%s]\n", subject); | 1157 fullbody = g_strdup_printf("[%s]\n", subject); |
1148 body = fullbody; | 1158 body = fullbody; |
1149 } | 1159 } |
1150 hk_message_in(bjid, rname, timestamp, body, type, encrypted); | 1160 hk_message_in(bjid, rname, timestamp, body, type, encrypted); |
1151 g_free(fullbody); | 1161 g_free(fullbody); |
1152 } else { | |
1153 scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", bjid); | |
1154 } | 1162 } |
1155 | 1163 |
1156 gotmessage_return: | 1164 gotmessage_return: |
1157 // Clean up and exit | 1165 // Clean up and exit |
1158 g_free(bjid); | 1166 g_free(bjid); |