marking.c
changeset 12 5ae14bc061b2
parent 11 f7c76b2c9900
child 14 01cdc293e2c2
equal deleted inserted replaced
11:f7c76b2c9900 12:5ae14bc061b2
    38 
    38 
    39 #define DESCRIPTION ( "Actions on multiple marked buddies\nProvides commands /mark and /marked" )
    39 #define DESCRIPTION ( "Actions on multiple marked buddies\nProvides commands /mark and /marked" )
    40 
    40 
    41 static module_info_t info_marking_experimental = {
    41 static module_info_t info_marking_experimental = {
    42 	.branch      = "experimental",
    42 	.branch      = "experimental",
    43 	.api         = 5,
    43 	.api         = 10,
    44 	.version     = PROJECT_VERSION,
    44 	.version     = PROJECT_VERSION,
    45 	.description = DESCRIPTION,
    45 	.description = DESCRIPTION,
    46 	.requires    = NULL,
    46 	.requires    = NULL,
    47 	.init        = marking_init,
    47 	.init        = marking_init,
    48 	.uninit      = marking_uninit,
    48 	.uninit      = marking_uninit,
    49 	.next        = NULL,
    49 	.next        = NULL,
    50 };
    50 };
    51 
    51 
    52 module_info_t info_marking = {
    52 module_info_t info_marking = {
    53 	.branch      = "dev",
    53 	.branch      = "dev",
    54 	.api         = 4,
    54 	.api         = 11,
    55 	.version     = PROJECT_VERSION,
    55 	.version     = PROJECT_VERSION,
    56 	.description = DESCRIPTION,
    56 	.description = DESCRIPTION,
    57 	.requires    = NULL,
    57 	.requires    = NULL,
    58 	.init        = marking_init,
    58 	.init        = marking_init,
    59 	.uninit      = marking_uninit,
    59 	.uninit      = marking_uninit,
   115 			marked = 1;
   115 			marked = 1;
   116 		}
   116 		}
   117 	}
   117 	}
   118 
   118 
   119 	if (marked == 1)
   119 	if (marked == 1)
   120 		scr_WriteIncomingMessage (jid ? jid : CURRENT_JID, "Marked", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
   120 		scr_write_incoming_message (jid ? jid : CURRENT_JID, "Marked", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
   121 	else if (marked == 0)
   121 	else if (marked == 0)
   122 		scr_WriteIncomingMessage (jid ? jid : CURRENT_JID, "Mark cleared", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
   122 		scr_write_incoming_message (jid ? jid : CURRENT_JID, "Mark cleared", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
   123 
   123 
   124 	if (jfree && jid)
   124 	if (jfree && jid)
   125 		g_free (jid);
   125 		g_free (jid);
   126 
   126 
   127 	free_arg_lst (args);
   127 	free_arg_lst (args);
   139 
   139 
   140 	if (!strcmp (cmd, "list")) {
   140 	if (!strcmp (cmd, "list")) {
   141 
   141 
   142 		GSList *mel;
   142 		GSList *mel;
   143 
   143 
   144 		scr_LogPrint (LPRINT_NORMAL, "Marked jids:");
   144 		scr_log_print (LPRINT_NORMAL, "Marked jids:");
   145 		for (mel = marked_jids; mel; mel = mel->next) {
   145 		for (mel = marked_jids; mel; mel = mel->next) {
   146 			char *jid = (char *) mel->data;
   146 			char *jid = (char *) mel->data;
   147 			scr_LogPrint (LPRINT_NORMAL, " * %s", jid);
   147 			scr_log_print (LPRINT_NORMAL, " * %s", jid);
   148 		}
   148 		}
   149 
   149 
   150 	} else if (!strcmp (cmd, "clear")) {
   150 	} else if (!strcmp (cmd, "clear")) {
   151 
   151 
   152 		GSList *mel;
   152 		GSList *mel;
   159 
   159 
   160 	} else if (!strcmp (cmd, "do")) {
   160 	} else if (!strcmp (cmd, "do")) {
   161 		char *format = args[1];
   161 		char *format = args[1];
   162 
   162 
   163 		if (!format)
   163 		if (!format)
   164 			scr_LogPrint (LPRINT_NORMAL, "You must specify action to do with marked jids");
   164 			scr_log_print (LPRINT_NORMAL, "You must specify action to do with marked jids");
   165 		else {
   165 		else {
   166 			char     *pos   = format;
   166 			char     *pos   = format;
   167 			gboolean  found = FALSE;
   167 			gboolean  found = FALSE;
   168 			gboolean  error = FALSE;
   168 			gboolean  error = FALSE;
   169 
   169 
   171 				if (*(pos + 1) == 's')
   171 				if (*(pos + 1) == 's')
   172 					found = TRUE;
   172 					found = TRUE;
   173 				else if (*(pos + 1) == '%')
   173 				else if (*(pos + 1) == '%')
   174 					++pos;
   174 					++pos;
   175 				else {
   175 				else {
   176 					scr_LogPrint (LPRINT_NORMAL, "Action string must not contain any other %%-sequesnces!");
   176 					scr_log_print (LPRINT_NORMAL, "Action string must not contain any other %%-sequesnces!");
   177 					error = TRUE;
   177 					error = TRUE;
   178 					break;
   178 					break;
   179 				}
   179 				}
   180 
   180 
   181 				++pos;
   181 				++pos;
   182 			}
   182 			}
   183 
   183 
   184 			if (!found)
   184 			if (!found)
   185 				scr_LogPrint (LPRINT_NORMAL, "Action string must contain one %%s!");
   185 				scr_log_print (LPRINT_NORMAL, "Action string must contain one %%s!");
   186 			else if (!error) {
   186 			else if (!error) {
   187 				GSList *mel;
   187 				GSList *mel;
   188 
   188 
   189 				for (mel = marked_jids; mel; mel = mel->next) {
   189 				for (mel = marked_jids; mel; mel = mel->next) {
   190 					char *jid     = (char *) mel->data;
   190 					char *jid     = (char *) mel->data;