Frameworks/libpurple.framework/Versions/2.10.12r8d2874a79747/Headers/transaction.h
branchadium-1.5.11
changeset 6014 fcb71cb71a3d
parent 5941 307f53385811
parent 6013 f8d0dc659e3f
child 6016 325e2ab3406f
equal deleted inserted replaced
5941:307f53385811 6014:fcb71cb71a3d
     1 /**
       
     2  * @file transaction.h MSN transaction functions
       
     3  *
       
     4  * purple
       
     5  *
       
     6  * Purple is the legal property of its developers, whose names are too numerous
       
     7  * to list here.  Please refer to the COPYRIGHT file distributed with this
       
     8  * source distribution.
       
     9  *
       
    10  * This program is free software; you can redistribute it and/or modify
       
    11  * it under the terms of the GNU General Public License as published by
       
    12  * the Free Software Foundation; either version 2 of the License, or
       
    13  * (at your option) any later version.
       
    14  *
       
    15  * This program is distributed in the hope that it will be useful,
       
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    18  * GNU General Public License for more details.
       
    19  *
       
    20  * You should have received a copy of the GNU General Public License
       
    21  * along with this program; if not, write to the Free Software
       
    22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
       
    23  */
       
    24 #ifndef MSN_TRANSACTION_H
       
    25 #define MSN_TRANSACTION_H
       
    26 
       
    27 #include "internal.h"
       
    28 
       
    29 typedef struct _MsnTransaction MsnTransaction;
       
    30 
       
    31 #include "cmdproc.h"
       
    32 #include "command.h"
       
    33 
       
    34 typedef void (*MsnTransCb)(MsnCmdProc *cmdproc, MsnCommand *cmd);
       
    35 typedef void (*MsnTimeoutCb)(MsnCmdProc *cmdproc, MsnTransaction *trans);
       
    36 typedef void (*MsnErrorCb)(MsnCmdProc *cmdproc, MsnTransaction *trans,
       
    37 						   int error);
       
    38 
       
    39 /**
       
    40  * A transaction. A sending command that will initiate the transaction.
       
    41  */
       
    42 struct _MsnTransaction
       
    43 {
       
    44 	MsnCmdProc *cmdproc;
       
    45 
       
    46 	gboolean saveable;	/**< Whether to save this transaction in the history */
       
    47 	unsigned int trId;	/**< The ID of this transaction, if it's being saved */
       
    48 
       
    49 	char *command;
       
    50 	char *params;
       
    51 
       
    52 	guint timer;
       
    53 
       
    54 	void *data; /**< The data to be used on the different callbacks. */
       
    55 	GDestroyNotify data_free;  /**< The function to free 'data', or @c NULL */
       
    56 
       
    57 	GHashTable *callbacks;
       
    58 	gboolean has_custom_callbacks;
       
    59 	MsnErrorCb error_cb;
       
    60 	MsnTimeoutCb timeout_cb;
       
    61 
       
    62 	char *payload;
       
    63 	size_t payload_len;
       
    64 
       
    65 	GQueue *queue;
       
    66 	MsnCommand *pendent_cmd; /**< The command that is waiting for the result of
       
    67 							   this transaction. */
       
    68 };
       
    69 
       
    70 MsnTransaction *msn_transaction_new(MsnCmdProc *cmdproc, const char *command,
       
    71 	const char *format, ...) G_GNUC_PRINTF(3, 4);
       
    72 void msn_transaction_destroy(MsnTransaction *trans);
       
    73 
       
    74 char *msn_transaction_to_string(MsnTransaction *trans);
       
    75 void msn_transaction_queue_cmd(MsnTransaction *trans, MsnCommand *cmd);
       
    76 void msn_transaction_unqueue_cmd(MsnTransaction *trans, MsnCmdProc *cmdproc);
       
    77 void msn_transaction_set_payload(MsnTransaction *trans,
       
    78 								 const char *payload, gsize payload_len);
       
    79 void msn_transaction_set_data(MsnTransaction *trans, void *data);
       
    80 void msn_transaction_set_data_free(MsnTransaction *trans, GDestroyNotify fn);
       
    81 void msn_transaction_set_saveable(MsnTransaction  *trans, gboolean saveable);
       
    82 void msn_transaction_add_cb(MsnTransaction *trans, char *answer,
       
    83 							MsnTransCb cb);
       
    84 void msn_transaction_set_error_cb(MsnTransaction *trans, MsnErrorCb cb);
       
    85 void msn_transaction_set_timeout_cb(MsnTransaction *trans, MsnTimeoutCb cb);
       
    86 
       
    87 #endif /* MSN_TRANSACTION_H */