I am here ;) amsn2 | +---- GUI | | | +---- clgroup.tcl | +---- clcontact.tcl | +---- clwidget.tcl | +---- Data | | | +---- account.tcl | +---- group.tcl | +---- contact.tcl | +---- groupmanager.tcl | +---- eventsystem.tcl | +---- Protocol | | | +---- telepathy2amsn.tcl | +---- telepathy | | | +------- ?????? | +---- Core | +---- ????
Phil P.S. By the way, why GLib was chosen for libmsn ? I knew that we had troubles we that but didn't followed this part of debate... :s Now, as J said how will we do ? I know ! Bye Bye J :p (Bad joke but bad mood too :s) Le Tuesday 08 August 2006 05:53, Youness Alaoui a écrit : > AFAIK it's also needed to run... > but you reminded me, wasn't it supposed to be commited to > trunk/amsn2/protocol/msnlib/ or something like that ? Was it Harry or Phil > who reviewed the directory hierarchy that we were supposed to set up ? > > KKRT > > On Mon, Aug 07, 2006 at 05:26:28PM -0400, J?r?me Gagnon-Voyer wrote: > > Do you need Glib only to compile or to run the software also > > > > J?r?me > > Courriel: [EMAIL PROTECTED] > > MSN Messenger: [EMAIL PROTECTED] > > iChat & AIM: [EMAIL PROTECTED] > > Skype: germinator5000 > > > > Le 7 ao?t 2006 ? 10:51, [EMAIL PROTECTED] a ?crit : > > >Revision: 7115 > > >Author: tjikkun > > >Date: 2006-08-07 07:51:28 -0700 (Mon, 07 Aug 2006) > > >ViewCVS: http://svn.sourceforge.net/amsn/?rev=7115&view=rev > > > > > >Log Message: > > >----------- > > >Initiall add of msnlib, the MSNP13 C/GLib msn library, to be used > > >mainly by amsn and telepathy > > > > > >Added Paths: > > >----------- > > > trunk/msnlib/ > > > trunk/msnlib/Makefile > > > trunk/msnlib/libmsn.txt > > > trunk/msnlib/msn-connection.c > > > trunk/msnlib/msn-connection.h > > > trunk/msnlib/msn.c > > > trunk/msnlib/msn.h > > >Added: trunk/msnlib/Makefile > > >=================================================================== > > >--- trunk/msnlib/Makefile (rev 0) > > >+++ trunk/msnlib/Makefile 2006-08-07 14:51:28 UTC (rev 7115) > > >@@ -0,0 +1,22 @@ > > >+CFLAGS = -g -Wall > > >+ > > >+CC = gcc > > >+LD = ld > > >+RM = rm -f > > >+LIBS = -lglib-2.0 -lgobject-2.0 > > >+INCLUDES = -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include > > >+OBJS = msn.o msn-connection.o > > >+SRCS = msn.c msn-connection.c > > >+HDRS = msn.h msn-connection.h > > >+ > > >+ > > >+all: msn > > >+ > > >+%.o: %.c > > >+ ${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< > > >+ > > >+msn: $(OBJS) > > >+ ${CC} -o msn ${OBJS} ${LIBS} > > >+ > > >+clean: > > >+ $(RM) msn *.o *~ > > > > > >Added: trunk/msnlib/libmsn.txt > > >=================================================================== > > >--- trunk/msnlib/libmsn.txt (rev 0) > > >+++ trunk/msnlib/libmsn.txt 2006-08-07 14:51:28 UTC (rev 7115) > > >@@ -0,0 +1,218 @@ > > >+libmsn > > >+------ > > >+ > > >+What it implements: > > >+- Connections > > >+- MSNP messages > > >+- Lists (TODO) > > >+- Contacts (TODO) > > >+ > > >+ > > >+GLib classes > > >+------------ > > >+ > > >+MsnConnection > > >+MsnMessage > > >+ > > >+ > > >+Other types > > >+----------- > > >+ > > >+typedef enum { > > >+ MSN_DS_CONNECTION, > > >+ MSN_NS_CONNECTION, > > >+ MSN_SB_CONNECTION > > >+} MsnConnectionType; > > >+ > > >+typedef void (MsnTweenerAuthCallback) (const gchar *account, const > > >gchar *password, const gchar *auth_string); > > >+ > > >+ > > >+Functions for connection handling > > >+--------------------------------- > > >+ > > >+gboolean msn_set_g_main_context(GMainContext *context) > > >+ context is the GMainContext that should be used in all > > >subsequent calls to libmsn functions. > > >+ > > >+ This function should always be called only once, and before > > >calling any other libmsn function. If msn_connection_new is called > > >before this function, it will do a msn_set_g_main_context(NULL), so > > >libmsn will use the default context. This function never fails on > > >the first call, and always fails on subsequent calls. Thus libmsn > > >will use the same context all the time. > > >+ > > >+ This function shall return TRUE on success or FALSE on > > >failure. > > >+ > > >+ > > >+MsnConnection *msn_connection_new(MsnConnectionType type) /* > > >Design Alternative 1 */ > > >+ type is either MSN_DS_CONNECTION, MSN_NS_CONNECTION or > > >MSN_SB_CONNECTION. > > >+ > > >+ MSN_DS_CONNECTION and MSN_NS_CONNECTION are handled the > > >same way, with one exception: NS allows the use of a cached NS > > >address, DS forces the function to connect to the dispatch server > > >messenger.hotmail.com:1863. > > >+ MSN_SB_CONNECTION will connect to a switchboard server. > > >+ > > >+ No addresses need to be passed because the connection > > >handler will always know them. Internally it keeps one NS server > > >address cached (the one that was successfully connected to most > > >recently). This is only cached in memory, so it is lost when the > > >process terminates. If the MSN_NS_CONNECTION type is used while no > > >address is in cache, it is handled as MSN_DS_CONNECTION. If an > > >address is in cache and MSN_DS_CONNECTION is used, the cached > > >address should not change. If the DS supplies an NS address > > >different from the one cached, the cached address should only > > >change once a connection to the new address succeeds. When > > >connecting with type MSN_NS_CONNECTION, while the previous NS or DS > > >connection redirected, then the address supplied in the redirection > > >command should be favored rather than a cached address. If that > > >connection fails, the next attempt will again use the cached > > >address. The function should only attempt to connect once when > > >called, and should just fail if the c > > > onnection could not be established. So the 'next attemp' is the > > >next call to the function. [Protocol sequences: VER, CVR] > > >+ > > >+ When connecting with type MSN_SB_CONNNECTION, a connection > > >will be made to a switchboard server. The address and the necessary > > >authentication info is obtained from the NS. If no NS connection is > > >active yet, this function will simply fail. [Protocol sequences: > > >XFR SB (on the NS connection), USR (on the brand-new SB connection)] > > >+ > > >+ This function executes synchronously, but if the connection > > >was established successfully, it will prepare the connection object > > >for asynchronous operation by adding sources to the GMainContext > > >specified by a call to msn_set_g_main_context(). If none has been > > >set, it defaults to NULL, which will make glib use the default > > >context. > > >+ > > >+ Failure is indicated by a NULL return value. > > >+ > > >+ > > >+/* A few macros for msn_connection_new Design Alternative 2 */ > > >+#define msn_connection_new_ns() msn_connection_new > > >(MSN_NS_CONNECTION, NULL) > > >+#define msn_connection_new_sb(ns_conn) msn_connection_new > > >(MSN_SB_CONNECTION, ns_conn) > > >+ > > >+MsnConnection *msn_connection_new(MsnConnectionType type, > > >MsnConnection *ns_conn) /* Design Alternative 2 */ > > >+ type is either MSN_DS_CONNECTION, MSN_NS_CONNECTION or > > >MSN_SB_CONNECTION. > > >+ ns_conn (see below) > > >+ > > >+ MSN_DS_CONNECTION and MSN_NS_CONNECTION are handled the > > >same way, with one exception: NS allows the use of a cached NS > > >address, DS forces the function to connect to the dispatch server > > >messenger.hotmail.com:1863. For these two types the ns_conn > > >parameter is ignored, and should be set to NULL. > > >+ > > >+ MSN_SB_CONNECTION will connect to a switchboard server. For > > >this type, ns_conn should be set to a pointer to a connection > > >object of type MSN_NS_CONNECTION, which should be connected and > > >authenticated. > > >+ > > >+ No addresses need to be passed because the connection > > >handler will always know them. Internally it keeps one NS server > > >address cached (the one that was successfully connected to most > > >recently). This is only cached in memory, so it is lost when the > > >process terminates. If the MSN_NS_CONNECTION type is used while no > > >address is in cache, it is handled as MSN_DS_CONNECTION. If an > > >address is in cache and MSN_DS_CONNECTION is used, the cached > > >address should not change. If the DS supplies an NS address > > >different from the one cached, the cached address should only > > >change once a connection to the new address succeeds. When > > >connecting with type MSN_NS_CONNECTION, while the previous NS or DS > > >connection redirected, then the address supplied in the redirection > > >command should be favored rather than a cached address. If that > > >connection fails, the next attempt will again use the cached > > >address. The function should only attempt to connect once when > > >called, and should just fail if the c > > > onnection could not be established. So the 'next attemp' is the > > >next call to the function. [Protocol sequences: VER, CVR] > > >+ > > >+ When connecting with type MSN_SB_CONNECTION, a connection > > >will be made to a switchboard server. The address and the necessary > > >authentication info are obtained from the NS. If no NS connection > > >is active yet, this function will simply fail. [Protocol sequences: > > >XFR SB (on the NS connection), USR (on the brand-new SB connection)] > > >+ > > >+ This function executes synchronously, but if the connection > > >was established successfully, it will prepare the connection object > > >for asynchronous operation by adding sources to the GMainContext > > >specified by a call to msn_set_g_main_context(). If none has been > > >set, it defaults to NULL, which will make glib use the default > > >context. > > >+ > > >+ Failure is indicated by a NULL return value. > > >+ > > >+ > > >+void msn_connection_login(MsnConnection *this, const gchar > > >*account, const gchar *password, MsnTweenerAuthCallback *twn_cb) > > >+ this Pointer to the object the method is invoked on. The pointer > > >must be obtained from msn_connection_new. > > >+ account The account name to use when logging in > > >+ password The password of the account > > >+ twn_cb A callback function as defined by: > > >+ typedef void (MsnTweenerAuthCallback) (const char *account, > > >const char *password, const char *auth_string); > > >+ account The account name to use when logging in, this is > > >the same pointer as was passed to msn_connection_login. > > >+ password The password of the account, this is the same > > >pointer as was passed to msn_connection_login. > > >+ auth_string is the string obtained from the NS in the USR > > >sequence before Tweener authentication. > > >+ > > >+ twn_cb may free the account and password strings, > > >libmsn will not use them after doing the callback. > > >+ twn_cb must not free auth_string, it is owned by > > >libmsn, and will therefore be freed by libmsn. > > >+ > > >+ This function will log into the MSN Messenger Service. > > >[Protocol sequence: USR, XFR NS] > > >+ It delegates the Tweener (HTTP + SOAP) part to the callback > > >function. > > >+ > > >+ This function should only be invoked on a DS or NS > > >connection that did not yet login. If invoked on a SB connection or > > >on a connection that logged in already, it must immediately return > > >with return value 0. > > >+ > > >+ This function executes asynchronously and returns > > >immediately after sending the initial USR. > > >+ > > >+ This function initiates a chain of actions: > > >+ 1. This function checks if this MsnConnection object has > > >authenticated already, if not, it sends the initial USR and updates > > >the object's state accordingly. This function returns here, the > > >rest of the actions are initiated from the glib mainloop. > > >+ 2. When the reply from the server arrives, and that is an > > >USR, the twn_cb callback function is called, which will send the > > >Tweener authentication request. This should be done using a HTTP > > >library that also utilises the glib mainloop, or is just non- > > >blocking so it can be wrapped to run in the mainloop. The twn_cb > > >function should make sure that a callback (let's call it > > >twn_reply_cb) is registered to catch the Tweener reply. The twn_cb > > >function must return without delay (i.e. it must not wait for the > > >HTTP response). > > >+ If the server sent an XFR reply instead of USR, an event is > > >fired to indicate that we're being redirected [Needs detail], and > > >the sequence ends here. > > >+ 3. On arrival of the Tweener response, twn_reply_cb will > > >extract the ticket from it, and call > > >msn_connection_set_login_ticket. That function will send the USR > > >message with the ticket and return. > > >+ 4. On arrival of the final USR response an event is fired > > >to indicate success or failure of the authentication. [Needs detail] > > >+ > > >+ > > >+void msn_connection_set_login_ticket(MsnConnection *this, const > > >gchar *ticket) > > >+ this Pointer to the object the method is invoked on. The pointer > > >must be obtained from msn_connection_new. > > >+ ticket is the authentication ticket from the tweener response. > > >+ > > >+ The ticket string may be freed after > > >msn_connection_set_login_ticket returns. > > >+ > > >+ For details about this function, see the description of > > >msn_connection_login. If this function is called while the object > > >is not waiting for a Tweener ticket, it will do nothing and return > > >immediately. > > >+ > > >+ > > >+void msn_connection_close(MsnConnection *this) > > >+ this Pointer to the object the method is invoked on. The pointer > > >must be obtained from msn_connection_new. > > >+ > > >+ This function will close the connection, and free any > > >resources related to it. > > >+ A user of libmsn must always call this if a connection will > > >not be used anymore, a connection is never closed automatically. > > >+ > > >+ Please note that this won't free the MsnConnection object > > >itself! The object will enter the disconnected state, and thus > > >cannot be used anymore. It should therefore be unref'ed so it will > > >eventually get freed. > > >+ > > >+ > > >+Functions for message handling > > >+------------------------------ > > >+ > > >+MsnMessage *msn_message_new() > > >+ > > >+ This function creates a new, empty MsnMessage object. > > >+ > > >+ > > >+MsnMessage *msn_message_from_string(const gchar *msgtext) > > >+ msgtext The message as a string. This will usually have been > > >received from the server. > > >+ > > >+ This function creates an MsnMessage object from the passed > > >string. > > >+ The returned MsnMessage object will be read only. > > >+ > > >+ > > >+const char *msn_message_get_header(MsnMessage *this, const gchar > > >*name) > > >+ name The name of the header to get. > > >+ > > >+ This function returns the content of the requested header, > > >or NULL if the message does not contain a header with the specified > > >name. The caller must not free the string returned by this function. > > >+ > > >+ > > >+const char *msn_message_get_body(MsnMessage *this) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new or msn_message_from_string. > > >+ > > >+ This function returns the content of the message body, or > > >NULL if the message has no body. > > >+ The caller must not free the string returned by this function. > > >+ > > >+ > > >+const char * msn_message_get_command(MsnMessage *this) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new or msn_message_from_string. > > >+ > > >+ This function returns the MSN protocol command in this > > >message. This is equal to the element at index 0 of the array > > >returned by msn_message_get_command_header. > > >+ The caller must not free the string returned by this function. > > >+ > > >+ > > >+const char * const * msn_message_get_command_header(MsnMessage *this) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new or msn_message_from_string. > > >+ > > >+ This function returns an array of strings. Each element of > > >the array holds one token from the very first line of the message > > >(the MSNP protocol command, and its arguments). The TrId is > > >omitted. The array will be NULL-terminated. > > >+ The caller must not free the returned array, nor any of the > > >strings it points to. > > >+ > > >+ > > >+int msn_message_get_trid(MsnMessage *this) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new or msn_message_from_string. > > >+ > > >+ This function returns the message's TrId, or -1 if it has no > > >TrId. > > >+ > > >+ > > >+void msn_message_set_header(MsnMessage *this, const gchar *name, > > >const gchar *value) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new. > > >+ name The name of the header to set. > > >+ value The value to set it to. > > >+ > > >+ This function sets a header with the specified name, and > > >assigns it the given value. If a header of that name already > > >exists, it is replaced. > > >+ Both the name and the value may be freed by the caller after > > >this function returns. > > >+ > > >+ > > >+void msn_message_set_body(MsnMessage *this, const gchar *body) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new. > > >+ body The message body > > >+ > > >+ This function sets the message body. If a body is already > > >set, it will be replaced. > > >+ The passed body may be freed by the caller after this > > >function returns. > > >+ > > >+ > > >+void msn_message_append_body(MsnMessage *this, const gchar *string) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new. > > >+ string The string to append to the message body. > > >+ > > >+ This function appends the given string to the message body. > > >+ If no body has been set yet, it operates like the > > >msn_message_set_body function. > > >+ The passed string may be freed by the caller after this > > >function returns. > > >+ > > >+ > > >+void msn_message_set_command_header(MsnMessage *this, const gchar > > >* const argv[]) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new or msn_message_from_string. > > >+ argv An array holding the MSNP command at index 0 and its > > >arguments at index 1 and up. The array must be NULL terminated. > > >+ > > >+ This function sets the first line of the message (the MSN > > >protocol command and its arguments). Each element of the argv array > > >holds one token. The TrId must be omitted. > > >+ The caller may free the array passed to this function after > > >this function returns. > > >+ > > >+ > > >+void msn_message_set_command_header_from_string(MsnMessage *this, > > >const gchar *command_hdr) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new or msn_message_from_string. > > >+ command_hdr Pointer to the command string. > > >+ > > >+ This function sets the first line of the message (the MSN > > >protocol command and its arguments). The TrId must be omitted. The > > >caller may free the string passed to this function after this > > >function returns. > > >+ > > >+ > > >+void msn_message_send(MsnMessage *this, MsnConnection *conn) > > >+ this Pointer to the object the method is invoked on. Must be > > >obtained from msn_message_new. > > >+ conn The connection where the message is to be sent. > > >+ > > >+ This function will assign the message a TrId (if required by > > >the protocol) and send it through the specified connection. > > >+ > > >+ > > > > > >Added: trunk/msnlib/msn-connection.c > > >=================================================================== > > >--- trunk/msnlib/msn-connection.c (rev 0) > > >+++ trunk/msnlib/msn-connection.c 2006-08-07 14:51:28 UTC (rev 7115) > > >@@ -0,0 +1,204 @@ > > >+/* > > >+ * msn-connection.c - Source for MsnConnection > > >+ * Copyright (C) 2006 ? > > >+ * Copyright (C) 2006 ? > > >+ * > > >+ * This library is free software; you can redistribute it and/or > > >+ * modify it under the terms of the GNU Lesser General Public > > >+ * License as published by the Free Software Foundation; either > > >+ * version 2.1 of the License, or (at your option) any later version. > > >+ * > > >+ * This library is distributed in the hope that it will be useful, > > >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of > > >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > >+ * Lesser General Public License for more details. > > >+ * > > >+ * You should have received a copy of the GNU Lesser General Public > > >+ * License along with this library; if not, write to the Free > > >Software > > >+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA > > >02110-1301 USA > > >+ */ > > >+ > > >+ > > >+#include <stdio.h> > > >+#include <stdlib.h> > > >+#include <string.h> > > >+#include <sys/types.h> > > >+#include <sys/socket.h> > > >+#include <unistd.h> > > >+#include <netdb.h> > > >+ > > >+#include "msn-connection.h" > > >+ > > >+#define g_printf printf > > >+ > > >+G_DEFINE_TYPE(MsnConnection, msn_connection, G_TYPE_OBJECT) > > >+ > > >+/* private structure */ > > >+typedef struct _MsnConnectionPrivate MsnConnectionPrivate; > > >+ > > >+struct _MsnConnectionPrivate > > >+{ > > >+ gboolean connected; > > >+ GIOChannel *channel; > > >+ guint trid; > > >+}; > > >+ > > >+#define MSN_CONNECTION_GET_PRIVATE(o) > > >(G_TYPE_INSTANCE_GET_PRIVATE ((o), MSN_TYPE_CONNECTION, > > >MsnConnectionPrivate)) > > >+ > > >+/* type definition stuff */ > > >+ > > >+static void > > >+msn_connection_init (MsnConnection *obj) > > >+{ > > >+ MsnConnectionPrivate *priv = MSN_CONNECTION_GET_PRIVATE (obj); > > >+ priv->connected = FALSE; > > >+ priv->trid = 1; > > >+} > > >+ > > >+static void msn_connection_dispose (GObject *object); > > >+static void msn_connection_finalize (GObject *object); > > >+ > > >+static void > > >+msn_connection_class_init (MsnConnectionClass *msn_connection_class) > > >+{ > > >+ GObjectClass *object_class = G_OBJECT_CLASS (msn_connection_class); > > >+ > > >+ g_type_class_add_private (msn_connection_class, sizeof > > >(MsnConnectionPrivate)); > > >+ > > >+ object_class->dispose = msn_connection_dispose; > > >+ object_class->finalize = msn_connection_finalize; > > >+} > > >+ > > >+void > > >+msn_connection_dispose (GObject *object) > > >+{ > > >+ MsnConnection *self = MSN_CONNECTION (object); > > >+ MsnConnectionPrivate *priv = MSN_CONNECTION_GET_PRIVATE (self); > > >+ > > >+ /* release any references held by the object here */ > > >+ > > >+ if (G_OBJECT_CLASS (msn_connection_parent_class)->dispose) > > >+ G_OBJECT_CLASS (msn_connection_parent_class)->dispose (object); > > >+} > > >+ > > >+void > > >+msn_connection_finalize (GObject *object) > > >+{ > > >+ MsnConnection *self = MSN_CONNECTION (object); > > >+ MsnConnectionPrivate *priv = MSN_CONNECTION_GET_PRIVATE (self); > > >+ > > >+ G_OBJECT_CLASS (msn_connection_parent_class)->finalize (object); > > >+} > > >+ > > >+struct sockaddr_in *get_msn_server(const char *server, gint port) { > > >+ /* > > >+ * if no server is specified (NULL) then MSN_DEFAULT_SERVER is taken > > >+ * if no port is specified (< 0) then MSN_DEFAULT_PORT is taken > > >+ */ > > >+ > > >+ struct sockaddr_in *msn_serv; > > >+ struct in_addr *addr; > > >+ struct hostent *host; > > >+ msn_serv = malloc((socklen_t) sizeof(struct sockaddr_in)); > > >+ if (msn_serv == NULL) { > > >+ // error > > >+ return NULL; > > >+ } > > >+ if (server == NULL) { > > >+ host = gethostbyname(MSN_DEFAULT_SERVER); > > >+ } else { > > >+ host = gethostbyname(server); > > >+ } > > >+ if (host == NULL) { > > >+ // error > > >+ return NULL; > > >+ } > > >+ addr = (struct in_addr*) host->h_addr_list[0]; > > >+ msn_serv->sin_family = AF_INET; > > >+ if (port < 0) { > > >+ port = MSN_DEFAULT_PORT; > > >+ } > > >+ msn_serv->sin_port = htons(port); > > >+ msn_serv->sin_addr.s_addr = addr->s_addr; > > >+ return msn_serv; > > >+} > > >+ > > >+ > > >+ > > >+/** > > >+ * msn_connection_connect > > >+ * > > >+ * > > >+ * Returns: MsnConnection if successful, NULL if not successfull. > > >+ */ > > >+MsnConnection *msn_connection_new(MsnConnectionType type) > > >+{ > > >+ MsnConnectionPrivate *priv; > > >+ MsnConnection *conn; > > >+ guint written; > > >+ gint port, i; > > >+ gchar *server, *buffer; > > >+ GError *error = NULL; > > >+ guint err, my_socket; > > >+ GIOStatus status; > > >+ > > >+ conn = g_object_new(MSN_TYPE_CONNECTION, NULL); > > >+ g_assert (MSN_IS_CONNECTION (conn)); > > >+ > > >+ priv = MSN_CONNECTION_GET_PRIVATE (conn); > > >+ > > >+ buffer = malloc(512 * sizeof(gchar)); > > >+ > > >+ /* Create a connection to given server */ > > >+ switch (type) { > > >+ case MSN_NS_CONNECTION: > > >+/* if (cached) { > > >+ port = cached_port; > > >+ server = cached_server; > > >+ break; > > >+ }*/ > > >+ case MSN_DS_CONNECTION: > > >+ port = -1; > > >+ server = NULL; > > >+ break; > > >+ case MSN_SB_CONNECTION: > > >+ break; > > >+ default: > > >+ break; > > >+ } > > >+ > > >+ my_socket = socket(AF_INET, SOCK_STREAM, 0); > > >+ if (my_socket == -1) { > > >+ g_debug("socket call failed"); > > >+ return NULL; > > >+ } > > >+ if (connect(my_socket, (struct sockaddr *) get_msn_server > > >(server, port), (socklen_t) sizeof(struct sockaddr_in)) != 0) { > > >+ g_debug("connect call failed"); > > >+ return NULL; > > >+ } > > >+ > > >+ /* Create G_IO_Channel */ > > >+ priv->channel = g_io_channel_unix_new(my_socket); > > >+ g_io_channel_set_encoding(priv->channel, NULL, NULL); > > >+ g_io_channel_set_line_term(priv->channel, "\r\n", 2); > > >+ g_printf("connected to server!\n"); > > >+ g_printf("sending VER 1 MSNP13 CVR0\\r\\n\n"); > > >+ status = g_io_channel_write_chars(priv->channel, "VER 1 MSNP13 > > >CVR0\r\n", -1, &written, &error); > > >+ g_io_channel_flush(priv->channel, &error); > > >+ g_printf("status: %i\n", status); > > >+ g_printf("written %i\n", written); > > >+ status = g_io_channel_read_chars(priv->channel, &buffer[0], 19, > > >&written, &error); > > >+ g_printf("status: %i\n", status); > > >+ g_printf("written %i\n", written); > > >+ g_printf("return: "); > > >+ for (i = 0; i < 19; i++) { > > >+ g_printf("%c", buffer[i]); > > >+ } > > >+ g_printf("\n"); > > >+/* g_printf("sending CVR 2 0x0409 winnt 5.1 i386 MSG80BETA > > >8.0.0566 msmsgs [EMAIL PROTECTED]"); > > >+ err = write(my_socket, "CVR 2 0x0409 winnt 5.1 i386 MSG80BETA > > >8.0.0566 msmsgs [EMAIL PROTECTED]", strlen("CVR 2 0x0409 > > >winnt 5.1 i386 MSG80BETA 8.0.0566 msmsgs [EMAIL PROTECTED] > > >\n") + 1);*/ > > >+/* g_io_channel_shutdown(priv->channel, TRUE, &error);*/ > > >+ close(my_socket); > > >+ return NULL; > > >+} > > >+ > > > > > >Added: trunk/msnlib/msn-connection.h > > >=================================================================== > > >--- trunk/msnlib/msn-connection.h (rev 0) > > >+++ trunk/msnlib/msn-connection.h 2006-08-07 14:51:28 UTC (rev 7115) > > >@@ -0,0 +1,69 @@ > > >+/* > > >+ * msn-connection.h - Header for MsnConnection > > >+ * Copyright (C) 2006 ? > > >+ * Copyright (C) 2006 ? > > >+ * > > >+ * This library is free software; you can redistribute it and/or > > >+ * modify it under the terms of the GNU Lesser General Public > > >+ * License as published by the Free Software Foundation; either > > >+ * version 2.1 of the License, or (at your option) any later version. > > >+ * > > >+ * This library is distributed in the hope that it will be useful, > > >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of > > >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > >+ * Lesser General Public License for more details. > > >+ * > > >+ * You should have received a copy of the GNU Lesser General Public > > >+ * License along with this library; if not, write to the Free > > >Software > > >+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA > > >02110-1301 USA > > >+ */ > > >+ > > >+#ifndef __MSN_CONNECTION_H__ > > >+#define __MSN_CONNECTION_H__ > > >+ > > >+#include <glib.h> > > >+#include <glib-object.h> > > >+ > > >+G_BEGIN_DECLS > > >+ > > >+#define MSN_DEFAULT_SERVER "messenger.hotmail.com" > > >+#define MSN_DEFAULT_PORT 1863 > > >+ > > >+typedef enum { > > >+ MSN_DS_CONNECTION, > > >+ MSN_NS_CONNECTION, > > >+ MSN_SB_CONNECTION > > >+} MsnConnectionType; > > >+ > > >+typedef struct _MsnConnection MsnConnection; > > >+typedef struct _MsnConnectionClass MsnConnectionClass; > > >+ > > >+struct _MsnConnectionClass { > > >+ GObjectClass parent_class; > > >+}; > > >+ > > >+struct _MsnConnection { > > >+ GObject parent; > > >+}; > > >+ > > >+GType msn_connection_get_type(void); > > >+ > > >+/* TYPE MACROS */ > > >+#define MSN_TYPE_CONNECTION \ > > >+ (msn_connection_get_type()) > > >+#define MSN_CONNECTION(obj) \ > > >+ (G_TYPE_CHECK_INSTANCE_CAST((obj), MSN_TYPE_CONNECTION, > > >MsnConnection)) > > >+#define MSN_CONNECTION_CLASS(klass) \ > > >+ (G_TYPE_CHECK_CLASS_CAST((klass), MSN_TYPE_CONNECTION, > > >MsnConnectionClass)) > > >+#define MSN_IS_CONNECTION(obj) \ > > >+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), MSN_TYPE_CONNECTION)) > > >+#define MSN_IS_CONNECTION_CLASS(klass) \ > > >+ (G_TYPE_CHECK_CLASS_TYPE((klass), MSN_TYPE_CONNECTION)) > > >+#define MSN_CONNECTION_GET_CLASS(obj) \ > > >+ (G_TYPE_INSTANCE_GET_CLASS ((obj), MSN_TYPE_CONNECTION, > > >MsnConnectionClass)) > > >+ > > >+MsnConnection *msn_connection_new(MsnConnectionType type); > > >+ > > >+G_END_DECLS > > >+ > > >+#endif /* #ifndef __MSN_CONNECTION_H__*/ > > > > > >Added: trunk/msnlib/msn.c > > >=================================================================== > > >--- trunk/msnlib/msn.c (rev 0) > > >+++ trunk/msnlib/msn.c 2006-08-07 14:51:28 UTC (rev 7115) > > >@@ -0,0 +1,43 @@ > > >+/* > > >+ * msn.c - > > >+ * Copyright (C) 2006 > > >+ * Copyright (C) 2006 > > >+ * > > >+ * This library is free software; you can redistribute it and/or > > >+ * modify it under the terms of the GNU Lesser General Public > > >+ * License as published by the Free Software Foundation; either > > >+ * version 2.1 of the License, or (at your option) any later version. > > >+ * > > >+ * This library is distributed in the hope that it will be useful, > > >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of > > >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > >+ * Lesser General Public License for more details. > > >+ * > > >+ * You should have received a copy of the GNU Lesser General Public > > >+ * License along with this library; if not, write to the Free > > >Software > > >+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA > > >02110-1301 USA > > >+ */ > > >+ > > >+#include <stdio.h> > > >+#include <stdlib.h> > > >+#include <string.h> > > >+#include <unistd.h> > > >+ > > >+#include "msn.h" > > >+#include "msn-connection.h" > > >+ > > >+GMainLoop *mainloop = NULL; > > >+MsnConnection *conn = NULL; > > >+ > > >+int > > >+main (int argc, > > >+ char **argv) > > >+{ > > >+ g_type_init(); > > >+ g_set_prgname("msn-test"); > > >+ conn = msn_connection_new(MSN_DS_CONNECTION); > > >+ mainloop = g_main_loop_new (NULL, FALSE); > > >+ g_main_loop_run (mainloop); > > >+ > > >+ return 0; > > >+} > > > > > >Added: trunk/msnlib/msn.h > > >=================================================================== > > >--- trunk/msnlib/msn.h (rev 0) > > >+++ trunk/msnlib/msn.h 2006-08-07 14:51:28 UTC (rev 7115) > > >@@ -0,0 +1,32 @@ > > >+/* > > >+ * msn.h - > > >+ * Copyright (C) 2006 > > >+ * Copyright (C) 2006 > > >+ * > > >+ * This library is free software; you can redistribute it and/or > > >+ * modify it under the terms of the GNU Lesser General Public > > >+ * License as published by the Free Software Foundation; either > > >+ * version 2.1 of the License, or (at your option) any later version. > > >+ * > > >+ * This library is distributed in the hope that it will be useful, > > >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of > > >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > >+ * Lesser General Public License for more details. > > >+ * > > >+ * You should have received a copy of the GNU Lesser General Public > > >+ * License along with this library; if not, write to the Free > > >Software > > >+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA > > >02110-1301 USA > > >+ */ > > >+ > > >+#ifndef __MSN_H__ > > >+#define __MSN_H__ > > >+ > > >+#include <glib.h> > > >+#include <glib-object.h> > > >+ > > >+G_BEGIN_DECLS > > >+ > > >+G_END_DECLS > > >+ > > >+#endif /* #ifndef __MSN_H__*/ > > >+ > > > > > > > > >This was sent by the SourceForge.net collaborative development > > >platform, the world's largest Open Source development site. > > > > > > > > >---------------------------------------------------------------------- > > >--- > > >Using Tomcat but need to do more? Need to support web services, > > >security? > > >Get stuff done quickly with pre-integrated technology to make your > > >job easier > > >Download IBM WebSphere Application Server v.1.0.1 based on Apache > > >Geronimo > > >http://sel.as-us.falkag.net/sel? > > >cmd=lnk&kid=120709&bid=263057&dat=121642 > > >_______________________________________________ > > >Amsn-commits mailing list > > >[EMAIL PROTECTED] > > >https://lists.sourceforge.net/lists/listinfo/amsn-commits > > > > ------------------------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job > > easier Download IBM WebSphere Application Server v.1.0.1 based on Apache > > Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > Amsn-devel mailing list > > Amsn-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/amsn-devel > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Amsn-devel mailing list > Amsn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/amsn-devel ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Amsn-devel mailing list Amsn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amsn-devel