Example #1
0
File: simple.c Project: ralight/ggz
PurpleCmdRet commande(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) {
	int argc,pid;
	char *joueur;
	char *jeu;
	joueur=g_strdup_printf("host%d", (int) (999.0*rand()/(RAND_MAX+1.0)));
	for(argc=0;args[argc];argc++);
	if(argc==0) {
		if(error)
			*error=g_strdup("Il faut spécifier un jeu, les jeux possibles sont(respectez la casse):\n-TicTacToe\n-Reversi\n-Chess");
		return PURPLE_CMD_RET_FAILED;
	}
	jeu=args[0];
	pid=fork();
	if(pid==0) {
		char **parms=malloc(4*sizeof(char *));
		char *sys_parm;
		if(purple_prefs_get_bool("/plugins/gtk/ggzpurple/guest"))
		 {
			parms[0]=joueur;
			parms[1]=jeu;
			sys_parm=g_strdup_printf("%s -u %s -g %s -s %s", GGZWRAPPER, parms[0], parms[1], purple_prefs_get_string("/plugins/gtk/ggzpurple/server"));
		 }
		else
		 {
			parms[0]=(char*)purple_prefs_get_string("/plugins/gtk/ggzpurple/login");
			parms[1]=jeu;
			sys_parm=g_strdup_printf("%s -u %s -g %s -p %s -s %s", GGZWRAPPER, parms[0], parms[1], purple_prefs_get_string("/plugins/gtk/ggzpurple/password"), purple_prefs_get_string("/plugins/gtk/ggzpurple/server"));
		 }
		parms[0]="sh";
		parms[1]="-c";
		parms[2]=sys_parm;
		parms[3]=NULL;
		printf("LAUNCH: %s,%s %s %s\n", "/bin/sh", parms[0], parms[1], parms[2]);
		execv("/bin/sh", parms);
		exit(0);
	} else if(pid>0) {
		if(purple_prefs_get_bool("/plugins/gtk/ggzpurple/guest")) purple_conv_im_send(PURPLE_CONV_IM(conv), g_strdup_printf("%s%s %s %s", HEADER, jeu,joueur, FOOTER));
		else purple_conv_im_send(PURPLE_CONV_IM(conv), g_strdup_printf("%s%s %s %s", HEADER, jeu,purple_prefs_get_string("/plugins/gtk/ggzpurple/login"), FOOTER));

		LastGamePID = pid;

		return PURPLE_CMD_RET_OK;
	} else {
		if(error)
		*error=strdup("Probleme de fork()");
		return PURPLE_CMD_RET_FAILED;
	}
}
Example #2
0
File: purple.c Project: echoline/rs
gboolean
pop(gpointer p) {
	char *reply = "";
	queue_t *q = (queue_t*)p;
	queue_item_t *item;

	if (q->len > 0) {
		item = q->q[0];

		q->len--;
		if (q->len > 0) {
			memmove(q->q, &(q->q[1]), q->len * sizeof(queue_item_t*));
	//		q->q = realloc(q->q, q->len * sizeof(queue_item_t*));
		}

		if (purple_conversation_get_type(item->conv) == PURPLE_CONV_TYPE_IM) {
//			reply = alice(item->name, item->msg, item->conv);
			purple_conv_im_send(PURPLE_CONV_IM(item->conv), item->msg);

		} else if (purple_conversation_get_type(item->conv) == PURPLE_CONV_TYPE_CHAT) {
//			reply = alice(item->name, item->msg, item->conv);
			purple_conv_chat_send(PURPLE_CONV_CHAT(item->conv), item->msg);

		}

		printf (NAME ": %s\n", reply);

		free(item->name);
		free(item->msg);
		free(item);
	}

	return 1;
}
//Callback function to send autoreply when buzz is received
static void buzz_cb(PurpleAccount *account, char *who, PurpleConversation *conv, guint type) {

    PurpleConvIm *im = purple_conversation_get_im_data(conv);
    const char *msg = purple_prefs_get_string(REPLY_MSG);

    purple_conv_im_send(im, msg);
}
void 
send_connect_request_message()
{
	PurpleAccount* account=purple_buddy_get_account(PURPLE_BUDDY(client_node));

	PurpleConversation *conv=purple_conversation_new (PURPLE_CONV_TYPE_IM, account, purple_buddy_get_name (PURPLE_BUDDY(client_node)));
	PurpleConvIm *im = purple_conversation_get_im_data(conv);

	const char* remote_message="sharedesk|request_connection|$SERVER_IP|$PORT|"
		"\nPlease start a vnc connection. Sample command line:"
		"\n$CLIENT_CMD"
		"\n|||";
	GRegex *port_regex1=g_regex_new("[$]CLIENT_CMD",0,0,NULL);
	char* msg1=g_regex_replace(port_regex1,remote_message,-1,0,purple_prefs_get_string(PREF_CLIENT_COMMAND_LINE),0,NULL);
	GRegex *port_regex2=g_regex_new("[$]PORT",0,0,NULL);
	char* msg2=g_regex_replace(port_regex2,msg1,-1,0,purple_value_get_string(port),0,NULL);
	GRegex *port_regex3=g_regex_new("[$]SERVER_IP",0,0,NULL);
	char* msg3=g_regex_replace(port_regex3,msg2,-1,0,purple_value_get_string(server_ip),0,NULL);

	purple_conv_im_send(im, msg3); 


	g_free(msg3);
	g_free(msg2);
	g_free(msg1);
	g_free(port_regex1);
	g_free(port_regex2);
	g_free(port_regex3);
}
Example #5
0
static void
bud(PurpleBuddy *who)
{
	PurpleAccount *acct = who->account;
	PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, who->name);

	purple_conv_im_send(PURPLE_CONV_IM(conv), "Hello!");
}
void SpectrumConversation::sendMessage(boost::shared_ptr<Swift::Message> &message) {
	// escape and send
	gchar *_markup = purple_markup_escape_text(message->getBody().c_str(), -1);
	if (purple_conversation_get_type(m_conv) == PURPLE_CONV_TYPE_IM) {
		purple_conv_im_send(PURPLE_CONV_IM(m_conv), _markup);
	}
	g_free(_markup);
}
Example #7
0
static void signed_on(PurpleConnection *gc)
{

	PurpleAccount *account = purple_connection_get_account(gc);
	
	PurpleConversation *conv;
	conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, input_address);
	purple_conv_im_send(PURPLE_CONV_IM(conv), input_message);
	exit(0);
}
static PurpleCmdRet radio_callback(PurpleConversation* conv,
        const gchar* cmd, 
        gchar** args,
        gchar** error,
        void* data) {
    
    char* radio_msg = radio_str(args[0]);

    purple_conv_im_send(PURPLE_CONV_IM(conv), radio_msg);

    return PURPLE_CMD_RET_OK;

}
Example #9
0
File: basic.c Project: ghetzel/zee
static void received_im_msg(PurpleAccount *account, char *sender, char *message,
                              PurpleConversation *conv, PurpleMessageFlags flags)
{

	if (conv==NULL)
  	{
  	conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender);
  	}

	printf("(%s) %s (%s): %s\n", purple_utf8_strftime("%H:%M:%S", NULL), sender, purple_conversation_get_name(conv), message);

        purple_conv_im_send(purple_conversation_get_im_data(conv), "THE GAME");
}
Example #10
0
static VALUE conversation_im_send(VALUE self, VALUE message) 
{
  PurpleConversation *conversation;
  Data_Get_Struct(self, PurpleConversation, conversation);
  PurpleConvIm *im_data =  PURPLE_CONV_IM(conversation);

  if (im_data == NULL) {
    return Qnil;
  }
  else {
    purple_conv_im_send(im_data, StringValueCStr(message));
    return Qtrue;
  }
}
Example #11
0
	void Buddy::Send (ConvIMMessage *msg)
	{
		auto name = purple_buddy_get_name (Buddy_);
		if (!name)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to get buddy name"
					<< Name_;

			const auto& notify = Util::MakeNotification ("Azoth VelvetBird",
					tr ("Unable to send message: protocol error.")
						.arg (name),
					Priority::Info);

			const auto& proxy = Account_->GetParentProtocol ()->GetCoreProxy ();
			proxy->GetEntityManager ()->HandleEntity (notify);

			return;
		}

		auto conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_IM,
				name, Account_->GetPurpleAcc ());
		if (!conv)
		{
			conv = purple_conversation_new (PURPLE_CONV_TYPE_IM, Account_->GetPurpleAcc (), name);
			if (!conv)
			{
				qWarning () << Q_FUNC_INFO
						<< "unable to create conversation with"
						<< name;

				const auto& notify = Util::MakeNotification ("Azoth VelvetBird",
						tr ("Unable to send message to %1: protocol error.")
							.arg (name),
						Priority::Info);

				const auto& proxy = Account_->GetParentProtocol ()->GetCoreProxy ();
				proxy->GetEntityManager ()->HandleEntity (notify);
				return;
			}

			conv->ui_data = this;
			purple_conversation_set_logging (conv, false);
		}

		Store (msg);

		purple_conv_im_send (PURPLE_CONV_IM (conv), msg->GetBody ().toUtf8 ().constData ());
	}
Example #12
0
static int purple_buddy_msg( struct im_connection *ic, char *who, char *message, int flags )
{
	PurpleConversation *conv;
	
	if( ( conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_IM,
	                                                    who, ic->proto_data ) ) == NULL )
	{
		conv = purple_conversation_new( PURPLE_CONV_TYPE_IM,
		                                ic->proto_data, who );
	}
	
	purple_conv_im_send( purple_conversation_get_im_data( conv ), message );
	
	return 1;
}
void run_lua(PurpleConversation *conv, msg_metadata_t msg)
{
    lua_State *L; 
    L = luaL_newstate(); 
    luaL_openlibs(L);  
    char lua_path[50];
    get_plugin_lua(lua_path);

    if (luaL_loadfile(L, lua_path))
    {
        lua_close(L);
        return;
    }

    if (lua_pcall(L, 0, 0, 0))  
    {
        lua_close(L);
        return;
    }

    lua_getglobal(L, "autorespond");
    lua_newtable(L); 

    push_val_to_lua_t(L, "text", msg.text);
    push_val_to_lua_t(L, "protocol_id", msg.protocol_id);
    push_val_to_lua_t(L, "remote_from_group", msg.remote_from_group);
    push_val_to_lua_t(L, "remote_username", msg.remote_username);
    push_val_to_lua_t(L, "remote_alias", msg.remote_alias);
    push_val_to_lua_t(L, "remote_status_id", msg.remote_status_id);
    push_val_to_lua_t(L, "remote_status_msg", msg.remote_status_msg);
    push_val_to_lua_t(L, "local_username", msg.local_username);
    push_val_to_lua_t(L, "local_alias", msg.local_alias);
    push_val_to_lua_t(L, "local_status_id", msg.local_status_id);
    push_val_to_lua_t(L, "local_status_msg", msg.local_status_msg);

    if (lua_pcall(L, 1, 1, 0)) /* Run function, !!! NRETURN=1 !!! */
    {
        lua_close(L);
        return;
    }
    const char* resp = lua_tostring(L, -1);
    if(resp)
    {
        purple_conv_im_send(purple_conversation_get_im_data(conv), resp);
    }
    lua_close(L); 
}
Example #14
0
static PurpleCmdRet
cmd_func(PurpleConversation *conv, const gchar *cmd, gchar **args,
		gchar *error, void *data)
{
	GString *msgstr = NULL;
	guint32 quotes = 0, quoteid = 0;
	
	msgstr = g_string_new("");

	srand(time(NULL));

	if(!strcmp(cmd, "bash")) {
		g_string_append(msgstr, "http://www.bash.org/?");
		quotes = BASH_QUOTES;
	} else {
		g_string_append(msgstr, "http://qdb.us/");
		quotes = QDB_QUOTES;
	}

	if(*args == NULL || args[0] == NULL)
		quoteid = (rand() % quotes) + 1;
	else
		quoteid = atoi(args[0]);

	if(quoteid > quotes)
		quoteid %= quotes;
	
	g_string_append_printf(msgstr, "%i", quoteid);

	switch(purple_conversation_get_type(conv)) {
		case PURPLE_CONV_TYPE_IM:
			purple_conv_im_send(PURPLE_CONV_IM(conv), msgstr->str);
			break;
		case PURPLE_CONV_TYPE_CHAT:
			purple_conv_chat_send(PURPLE_CONV_CHAT(conv), msgstr->str);
			break;
		default:
			g_string_free(msgstr, TRUE);
			return PURPLE_CMD_RET_FAILED;
	}

	g_string_free(msgstr, TRUE);

	return PURPLE_CMD_RET_OK;
}
Example #15
0
static void pipe_handle_message(struct purple_message *message) {
	LM_DBG("handling message cmd\n");
	PurpleAccount *account = NULL;
	extern_account_t *accounts = NULL;
	extern_user_t *users = NULL;
	int naccounts = 0, nusers = 0;
	int i, j;

	PurpleConversation *conv = NULL;
	LM_DBG("calling find_accounts(\"%s\", &naccounts)\n", message->from);
	accounts = find_accounts(message->from, &naccounts);
	LM_DBG("found %d extra account(s) for <%s>", naccounts, message->from);

	LM_DBG("calling find_users(\"%s\", &nusers)\n", message->to);
	users = find_users(message->to, &nusers);
	LM_DBG("found %d extra user(s) for <%s>", nusers, message->to);

	for (i = 0; i < naccounts; i++) {
		LM_DBG("calling client_find_account(\"%s\")\n", accounts[i].username);
		account = client_find_account(&accounts[i]);
		if ((account) && purple_account_is_connected(account)) {
			//enable_account(account);
			for (j = 0; j < nusers; j++) {
				if (!strcmp(accounts[i].protocol, users[j].protocol)) {
					LM_DBG("mathing protocol found: %s\n", accounts[i].protocol);
					conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, users[j].username, account);
					if (conv == NULL)
						conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, users[j].username);
					purple_conv_im_send(purple_conversation_get_im_data(conv), message->body);
					break;
				}
			}
		}
		else if (account == NULL)
			LM_DBG("not account found neither created\n");
		else if (purple_account_is_disconnected(account))
			LM_DBG("account is disconnected cannot send message\n");
	}
	if (accounts)
		extern_account_free(accounts, naccounts);
	if (users)
		extern_user_free(users, nusers);

}
void music_messaging_change_confirmed(const int session, const char *command, const char *parameters)
{
	
	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
	
	if (mmconv->started)
	{
		if (mmconv->originator)
		{
			GString *to_send = g_string_new("");
			g_string_append_printf(to_send, "##MM## confirm %s %s##MM##", command, parameters);
			
			purple_conv_im_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
		} else
		{
			/* Do nothing. If they aren't the originator, then they can't confirm. */
		}
	}
	
}
Example #17
0
static PurpleCmdRet
send_to_all(PurpleConversation *conv, const gchar *cmd, gchar **markup,
        gchar *error, void *data)
{
    PurpleConversation *conversation = NULL;
    GList *conversations = purple_get_conversations();
    while(conversations != NULL)
    {
        conversation = conversations->data;
        if(conv->type == PURPLE_CONV_TYPE_IM)
            purple_conv_im_send(PURPLE_CONV_IM(conversation), markup[0]);
        else if(conv->type == PURPLE_CONV_TYPE_CHAT)
            purple_conv_chat_send(PURPLE_CONV_CHAT(conversation), markup[0]);

        conversations = conversations->next;
    }
    //g_free(msg);

    return PURPLE_CMD_RET_OK;
}
Example #18
0
static int purple_buddy_msg(struct im_connection *ic, char *who, char *message, int flags)
{
	PurpleConversation *conv;
	struct purple_data *pd = ic->proto_data;

	if (!strncmp(who, PURPLE_REQUEST_HANDLE, sizeof(PURPLE_REQUEST_HANDLE) - 1)) {
		guint request_id = atoi(who + sizeof(PURPLE_REQUEST_HANDLE));
		purple_request_input_callback(request_id, ic, message, who);
		return 1;
	}

	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
	                                                  who, pd->account)) == NULL) {
		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
		                               pd->account, who);
	}

	purple_conv_im_send(purple_conversation_get_im_data(conv), message);

	return 1;
}
Example #19
0
static VALUE common_send(VALUE self, VALUE name, VALUE message)
{
  PurpleAccount *account;
  Data_Get_Struct(self, PurpleAccount, account);
  
  if (purple_account_is_connected(account)) {
     PurpleBuddy* buddy = purple_find_buddy(account, RSTRING_PTR(name));
     if (buddy != NULL) {
       PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, RSTRING_PTR(name), account);
       if (conv == NULL) {
         conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
                                        buddy->account, buddy->name);
       }
       purple_conv_im_send(PURPLE_CONV_IM(conv), RSTRING_PTR(message));
       return INT2FIX(0);
     } else {
       return Qnil;
     }
  } else {
    return Qnil;    
  }
}
Example #20
0
gboolean jidgin_worker_send_im(PurpleAccount *account, PurpleConversation *conv, pJidginMsg pmsg) {
  PurpleBuddy *buddy;
  char *reply;
  pJidginSetting setting = jidgin_core_get_purple_settings();

  if (!account) {
    account = jidgin_core_get_primary_account();
  }

  if (purple_account_is_disconnected(account)) {
    jidgin_log(LOG_INFO, "[jidgin_worker_send_im]%s disconnected\n",
        purple_account_get_username(account));
    jidgin_worker_cb_retry(account);
    return FALSE;
  }

  if (!conv) {
    buddy = purple_find_buddy(account, pmsg->from);
    if (!buddy) {
      if (setting && setting->is_force_mt)
        buddy = purple_buddy_new(account, pmsg->from, pmsg->from);
      else
        return FALSE;
    }
    conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, buddy->account, pmsg->from);
  }

  jidgin_log(LOG_INFO, "[jidgin_worker_send_im]%s %s\n",
      purple_account_get_username(account), pmsg->from);

  if (jidgin_intercept_postrouting(pmsg->msg, &reply)) {
    g_free(pmsg->msg);
    pmsg->msg = reply;
  }
  purple_conv_im_send(PURPLE_CONV_IM(conv), pmsg->msg);

  return TRUE;
}
/* Exported functions */
void music_messaging_change_request(const int session, const char *command, const char *parameters)
{
	
	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
	
	if (mmconv->started)
	{
		if (mmconv->originator)
		{
			char *name = (mmconv->conv)->name;
			send_change_request (session, name, command, parameters);
		} else
		{
			GString *to_send = g_string_new("");
			g_string_append_printf(to_send, "##MM## request %s %s##MM##", command, parameters);
			
			purple_conv_im_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
			
			purple_debug_misc("musicmessaging", "Sent request: %s\n", to_send->str);
		}
	}
			
}
static void write_conv(PurpleConversation *conv, const char *who, const char *alias,
        const char *message, PurpleMessageFlags flags, time_t mtime) {
    if (!(flags & PURPLE_MESSAGE_RECV))
        return;

    const char *name;
    if (alias && *alias)
        name = alias;
    else if (who && *who)
        name = who;
    else
        name = NULL;

    printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv),
            purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)),
            name, message);

    time_t rawtime;

    char send_message[5120];
    get_answer(message, &send_message[0]);
    //printf("%s", send_message);
    purple_conv_im_send(PURPLE_CONV_IM(conv), send_message);
}
Example #23
0
void taim_send(char*ptosend,char*uid,char*buffer) {
  PurpleConversation *p_purpcon=0;

  taim_account *acct = 0;
  taim_session *pses = 0;

  char	*sn = ptosend,
        *msg = 0;

  int 	bound = strlen(ptosend),
        ix,
        userno;

  char	userchar;

  // First get the uid
  pses = uid_find(uid);

  if(pses->pses->account == NULL)
  {
    taim_new_account(pses);
    return;
  }

  acct = pses->pses->account;

  for(ix = 0;ix < bound;ix++) {
    if(sn[ix] == '.') {
      sn[ix] = 0;
      msg = sn + ix + 1;
      break;
    }
  }

  // Look for the conversation
  // '.' was replaced with '0' above!
  if(sn[1] == 0) {
    d("alias");
    sscanf(sn, "%c", &userchar);
    userchar |= 0x20;
    for(userno = 0;userno < MAX_USERS_TO_SHOW;userno++) {
      if(ALIAS_LOOKUP[userno] == userchar) {
        break;
      }
    }

    if(userno == MAX_USERS_TO_SHOW) {
      return;
    }

    sn = uid_get_user(uid, userno);
    if(sn == 0) {
      return;
    }
  }

  bound = acct->conversation_size_current;
  // Now find the conversation in the account
  for(ix = 0; ix < bound; ix++) {
    if(acct->conversation_list[ix]->name != 0) {
      if(!strcmp(acct->conversation_list[ix]->name, sn)) {
        p_purpcon = acct->conversation_list[ix]; 
        break;
      }
    } else {
      p_purpcon = 0;
      break;
    }
  }

  if(p_purpcon == 0) {
    // Make a new convo
    p_purpcon = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct->account, sn);

    if(p_purpcon != NULL) {	
      taim_conv_add(sn, p_purpcon);
    } else {
      // BUG BUG
      snprintf(buffer + strlen(buffer), 
          BUFFER_SIZE-strlen(buffer),
          "User Authentication Failed\n");

      return;
    }
  }
  snprintf(buffer + strlen(buffer),
      BUFFER_SIZE-strlen(buffer),
      "[%s:%s]\n",
      sn,
      msg);

  purple_conv_im_send(
      p_purpcon->u.im,
      msg);

  return;
}
Example #24
0
File: simple.c Project: ralight/ggz
static void message_recu2(PurpleAccount *acct,char **sender, char **buffer,int flags,  PurpleConversation *conv,void *data) {

	GtkWidget *pDialog;

	if(*buffer==NULL)
		return;

	if(strstr(*buffer, HEADER)==NULL)
		return;

	char *joueur=NULL;
	char *jeu=NULL;
	jeu=strstr(*buffer, HEADER);
	jeu+=strlen(HEADER);
	jeu[strlen(jeu)-strlen(strstr(jeu, FOOTER))]='\0';
	joueur=index(jeu, ' ');

	if(strstr(jeu,"refuse_game") != NULL)
	{
    		pDialog = gtk_message_dialog_new (NULL,
        		GTK_DIALOG_MODAL,
        		GTK_MESSAGE_QUESTION,
        		GTK_BUTTONS_OK,
        		g_strdup_printf("Votre partie avec %s a été refusée/annulée !",*sender));
		gtk_dialog_run(GTK_DIALOG(pDialog));
		gtk_widget_destroy(pDialog);

		//printf("Test : %d\n",LastGamePID);
		//kill(LastGamePID, SIGKILL);

		*buffer = NULL;

		return;
	}

	if(joueur==NULL) {
		printf("Pas de joueur mais un jeu: %s\n", jeu);
		return;
	}
	joueur[0]='\0';
	joueur++;
	if(index(joueur, ' ')) {
		joueur[strlen(joueur) - strlen(index(joueur, ' '))]='\0';
	}

    	pDialog = gtk_message_dialog_new (NULL,
        	GTK_DIALOG_MODAL,
        	GTK_MESSAGE_QUESTION,
        	GTK_BUTTONS_YES_NO,
        	"%s/%s vous propose une partie de %s, voulez vous accepter ?",*sender,joueur,jeu);

	if(gtk_dialog_run(GTK_DIALOG(pDialog)) == GTK_RESPONSE_NO)
	{
		gtk_widget_destroy(pDialog);

		purple_conv_im_send(PURPLE_CONV_IM(purple_conversation_new(PURPLE_CONV_TYPE_IM,acct,*sender)), g_strdup_printf("%srefuse_game %s", HEADER, FOOTER));
		*buffer=NULL;
		return;
	}

	gtk_widget_destroy(pDialog);

	int pid=0;
	pid=fork();
	if(pid==0) {
		//L'enfant trop fort hein :)
		char **parms=malloc(4*sizeof(char *));
		char *sys_parm;
		if(purple_prefs_get_bool("/plugins/gtk/ggzpurple/guest"))
		 {
			parms[1]=g_strdup_printf("guest%d", (int) (999.0*rand()/(RAND_MAX+1.0)));
			parms[2]=joueur;
			sys_parm=g_strdup_printf("%s -u %s -d %s -g %s -s %s", GGZWRAPPER, parms[1], parms[2], jeu, purple_prefs_get_string("/plugins/gtk/ggzpurple/server"));
		 }
		else
		 {
			parms[1]=(char*)purple_prefs_get_string("/plugins/gtk/ggzpurple/login");
			parms[2]=joueur;
			sys_parm=g_strdup_printf("%s -u %s -d %s -g %s -p %s -s %s", GGZWRAPPER, parms[1], parms[2], jeu, purple_prefs_get_string("/plugins/gtk/ggzpurple/password"), purple_prefs_get_string("/plugins/gtk/ggzpurple/server"));
		 }
		parms[0]="sh";
		parms[1]="-c";
		parms[2]=sys_parm;
		parms[3]=NULL;
		printf("LAUNCH: %s,%s %s %s\n", "/bin/sh", parms[0], parms[1], parms[2]);
		execv("/bin/sh", parms);
		exit(0);
	} else if(pid>0) {
		//Ici c'est le pere je vous apprends beaucoup de choses non? ;)
		//LastGamePID = pid;
	} else {
		//Ici c'est quand y a eu une erreur........
	}
	//Ca sert a rien d'afficher ce somtueux message ;)
	*buffer=NULL;
}
Example #25
0
xmlnode * _h_elim_message ( const char *name ,
                            const char *id   ,
                            SEXP_VALUE *args ,
                            gpointer data    )
{
    fprintf(stderr, "(elim-debug entered _h_elim_message)");
    ASSERT_ALISTP( args, id, name );
    
    elim_ping();

    const char *aname = ALIST_VAL_STR( args, "account-name" );
    const char *proto = ALIST_VAL_STR( args, "im-protocol"  );
    gpointer    auid  = ALIST_VAL_PTR( args, "account-uid"  );

    PurpleAccount *acct = 
      auid ? find_acct_by_uid( auid ) : purple_accounts_find( aname, proto );

    if( !acct )
    {
        sexp_val_free( args );
        return response_error( ENXIO, id, name, "unknown account" );
    }

    PurpleConversationType pt = PURPLE_CONV_TYPE_UNKNOWN;
    gpointer             cuid = ALIST_VAL_PTR( args, "conv-uid"  );
    const char         *cname = ALIST_VAL_STR( args, "conv-name" );
    PurpleConversation    *pc = find_conv_by_acct_uid( acct, cuid );

    if  ( pc ) pt = purple_conversation_get_type( pc );
    else
    {
        pt = PURPLE_CONV_TYPE_ANY;
        pc = purple_find_conversation_with_account( pt, cname, acct );
        if( !pc )
        {
            pt = PURPLE_CONV_TYPE_IM;
            pc = purple_conversation_new( pt, acct, cname );
        }
        else { pt = purple_conversation_get_type( pc ); }
    }

    if( !pc )
    {
        sexp_val_free( args );
        return response_error( ENXIO, id, name, "new conversation failed" );
    }

    PurpleConvIm   *pci = NULL;
    PurpleConvChat *pcc = NULL;
    const char     *msg = ALIST_VAL_STRING( args, "text" );
    char           *esc = g_markup_escape_text( msg, -1 );
    int             len = strlen( esc );

    switch( pt )
    {
      case PURPLE_CONV_TYPE_IM:
        pci = purple_conversation_get_im_data( pc );
        purple_conv_im_send( pci, esc );
        break;
      case PURPLE_CONV_TYPE_CHAT:
        pcc = purple_conversation_get_chat_data( pc );
        purple_conv_chat_send( pcc, esc );
        break;
      default:
        g_free       ( esc  );
        sexp_val_free( args );
        return response_error( EINVAL, id, name, "unknown conversation type" );
    }

    xmlnode *rval = xnode_new( "alist" );
    AL_INT( rval, "bytes"    , len     );
    AL_PTR( rval, "conv-uid" , pc      );
    AL_STR( rval, "conv-name", purple_conversation_get_name(pc) );

    g_free       ( esc  );
    sexp_val_free( args );
    fprintf(stderr, "(elim-debug leaving _h_elim_message)");
    return response_value( 0, id, name, rval );
}
Example #26
0
void IMInvoker::send(void *userdata, const std::string event) {
	// we are in the thread that manages all of libpurple
	EventContext* ctx = (EventContext*)userdata;

	if (!ctx)
		return;

	if (!ctx->instance || !ctx->instance->_account) {
		ctx->instance->returnErrorExecution("No account available");
		delete(ctx);
		return;
	}

	if (iequals(ctx->sendReq.name, "im.send")) {
		std::string receiver;
		Event::getParam(ctx->sendReq.params, "receiver", receiver);

		Data data;
		Event::getParam(ctx->sendReq.params, "data", data);

#if LIBPURPLE_VERSION_MAJOR >= 3
		PurpleIMConversation* conv = purple_im_conversation_new(ctx->instance->_account, receiver.c_str());
		if (ctx->sendReq.content.length() > 0)
			purple_conversation_send(PURPLE_CONVERSATION(conv), ctx->sendReq.content.c_str());
#else
		PurpleConversation* conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, ctx->instance->_account, receiver.c_str());
		if (ctx->sendReq.content.length() > 0)
			purple_conv_im_send(purple_conversation_get_im_data(conv), ctx->sendReq.content.c_str());
#endif

#if 0
		if (data.binary) {
			PurpleConnection *gc = purple_account_get_connection(ctx->instance->_account);
			PurplePlugin *prpl;
			PurplePluginProtocolInfo *prpl_info;


			if (gc) {
				prpl = purple_connection_get_prpl(gc);
				prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);

//					if (prpl_info && prpl_info->new_xfer) {
//						PurpleXfer* xfer = (prpl_info->new_xfer)(purple_account_get_connection(ctx->instance->_account), receiver.c_str());
//						purple_xfer_set_local_filename(xfer, "/Users/sradomski/Documents/W3C Standards.pdf");
//						purple_xfer_set_filename(xfer, "asdfadsf.pdf");
//						purple_xfer_request(xfer);
//						purple_xfer_request_accepted(xfer, "/Users/sradomski/Documents/W3C Standards.pdf");
//					}

				//Set the filename
//					purple_xfer_set_local_filename(xfer, [[fileTransfer localFilename] UTF8String]);
//					purple_xfer_set_filename(xfer, [[[fileTransfer localFilename] lastPathComponent] UTF8String]);
//					xfer->ui_data
//					purple_xfer_request(xfer);

				serv_send_file(gc, "sradomski@localhost", "/Users/sradomski/Documents/W3C Standards.pdf");
//					if (prpl_info->send_file && (prpl_info->can_receive_file && prpl_info->can_receive_file(gc, receiver.c_str()))) {
//						prpl_info->send_file(gc, receiver.c_str(), "/Users/sradomski/Documents/W3C Standards.pdf");
//					}
//						prpl_info->send_raw(gc, data.binary->data, data.binary->size);
			}

		}
#endif
	} else if (iequals(ctx->sendReq.name, "im.buddy.add")) {
		std::string buddyName;
		Event::getParam(ctx->sendReq.params, "name", buddyName);

		std::string reqMsg;
		Event::getParam(ctx->sendReq.params, "msg", reqMsg);

		PurpleBuddy* buddy = purple_buddy_new(ctx->instance->_account, buddyName.c_str(), NULL);
		purple_blist_add_buddy(buddy, NULL, NULL, NULL);
#if LIBPURPLE_VERSION_MAJOR >= 3
		purple_account_add_buddy(ctx->instance->_account, buddy, reqMsg.c_str());
#else
		purple_account_add_buddy(ctx->instance->_account, buddy);
#endif

	} else if (iequals(ctx->sendReq.name, "im.buddy.remove")) {
		std::string buddyName;
		Event::getParam(ctx->sendReq.params, "name", buddyName);

#if LIBPURPLE_VERSION_MAJOR >= 3
		PurpleBuddy* buddy = purple_blist_find_buddy(ctx->instance->_account, buddyName.c_str());
		if (PURPLE_IS_BUDDY(buddy)) {
			purple_account_remove_buddy(ctx->instance->_account, buddy, purple_buddy_get_group(buddy));
			purple_blist_remove_buddy(buddy);
		}
#else
		PurpleBuddy* buddy = purple_find_buddy(ctx->instance->_account, buddyName.c_str());
		purple_account_remove_buddy(ctx->instance->_account, buddy, purple_buddy_get_group(buddy));
		purple_blist_remove_buddy(buddy);

#endif
	}

	delete(ctx);
}
Example #27
0
/*** Conversation uiops ***/
  static void
taim_write_conv(PurpleConversation *conv, const char *who, const char *alias,
    const char *message, PurpleMessageFlags flags, time_t mtime)
{
  const char *name;

  int ix;

  char isdone = 0;

  taim_pipe *ppipe;
  taim_account *pacct;
  taim_session *pses;

  if(!strncmp(message, "!shell", 6)) {
    char char_shell[2048] = {0};
    shellout((char*)(message+6), char_shell, 2048);
    d(char_shell);
    purple_conv_im_send(conv->u.im, char_shell);
  } else if(!strcmp(message, "!debug")) {
    char char_debug[4096] = {0};

    debug(char_debug, 4096);
    d(char_debug);
    purple_conv_im_send(conv->u.im, char_debug);
  } else if(!strcmp(message, "!quit")) {
    do_exit();
  }

  if (alias && *alias) {
    name = alias;
  } else if (who && *who) {
    name = who;
  } else {
    name = NULL;
  }

  //	if(strcmp(g_account->username,name))
  //	{
  pacct = taim_conv_add(name, conv);

  if(pacct == NULL) {
    return;
  }

  for(ix = 0; ix < pacct->session_size_current; ix++) {
    pses = pacct->session_list[ix];

    pthread_mutex_lock(&pses->pses->pipe_mutex); {
      for(	ppipe = pses->pses->cpipe;
          ppipe->next;
          ppipe = ppipe->next)
      {
        if(!strncmp(name, ppipe->user, strlen(ppipe->user))) {
          snprintf(ppipe->data+strlen(ppipe->data), PIPE_BUFFER, "|%s", message);
          isdone = 1;
          taim_new_account(pses);
          break;
        }
      }

      if(!isdone) {
        strcpy(pses->pses->ppipe->data, message);
        strcpy(pses->pses->ppipe->user, name);
        pses->pses->ppipe->next = (taim_pipe*)malloc(sizeof(taim_pipe));
        pses->pses->ppipe->next->data[0] = 0;
        pses->pses->ppipe->next->user[0] = 0;
        pses->pses->ppipe->next->next = 0;
        pses->pses->ppipe = pses->pses->ppipe->next;
      }		
    }
    pthread_mutex_unlock(&pses->pses->pipe_mutex);
  }
  //	}
}