diff src/protocols/qq/sendqueue.c @ 14021:ef8490f9e823

[gaim-migrate @ 16618] Replaced all C++-style comments with C-style ones. Cleaned up some comments and implemented a more consistent formatting scheme. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Wed, 02 Aug 2006 15:35:36 +0000
parents 983fd420e86b
children
line wrap: on
line diff
--- a/src/protocols/qq/sendqueue.c	Wed Aug 02 13:37:13 2006 +0000
+++ b/src/protocols/qq/sendqueue.c	Wed Aug 02 15:35:36 2006 +0000
@@ -20,20 +20,18 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-// START OF FILE
-/*****************************************************************************/
-#include "connection.h"		// GaimConnection
-#include "debug.h"		// gaim_debug
-#include "internal.h"		// _("get_text")
-#include "notify.h"		// gaim_notify
-#include "prefs.h"		// gaim_prefs_get_bool
-#include "request.h"		// gaim_request_action
+#include "connection.h"
+#include "debug.h"
+#include "internal.h"
+#include "notify.h"
+#include "prefs.h"
+#include "request.h"
 
-#include "header_info.h"	// cmd alias
-#include "qq_proxy.h"		// qq_proxy_write
+#include "header_info.h"
+#include "qq_proxy.h"
 #include "sendqueue.h"
 
-#define QQ_RESEND_MAX               5	// max resend per packet
+#define QQ_RESEND_MAX               5	/* max resend per packet */
 
 typedef struct _gc_and_packet gc_and_packet;
 
@@ -42,9 +40,8 @@
 	qq_sendpacket *packet;
 };
 
-/*****************************************************************************/
-// Remove a packet with send_seq from sendqueue
-void qq_sendqueue_remove(qq_data * qd, guint16 send_seq)
+/* Remove a packet with send_seq from sendqueue */
+void qq_sendqueue_remove(qq_data *qd, guint16 send_seq)
 {
 	GList *list;
 	qq_sendpacket *p;
@@ -61,12 +58,11 @@
 			break;
 		}
 		list = list->next;
-	}			// while
-}				// qq_sendqueue_remove
-
-/*****************************************************************************/
-// clean up sendqueue and free all contents
-void qq_sendqueue_free(qq_data * qd)
+	}
+}
+		
+/* clean up sendqueue and free all contents */
+void qq_sendqueue_free(qq_data *qd)
 {
 	qq_sendpacket *p;
 	gint i;
@@ -80,12 +76,11 @@
 		i++;
 	}
 	gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d packets in sendqueue are freed!\n", i);
-}				// qq_sendqueue_free
+}
 
-/*****************************************************************************/
-// packet lost, agree to send again, (and will NOT prompt again)
-// it is removed only when ack-ed by server
-static void _qq_send_again(gc_and_packet * gp)
+/* packet lost, agree to send again, (and will NOT prompt again)
+ * it is removed only when ack-ed by server */
+static void _qq_send_again(gc_and_packet *gp)
 {
 	GaimConnection *gc;
 	qq_data *qd;
@@ -106,11 +101,10 @@
 		qq_proxy_write(qd, packet->buf, packet->len);
 	}
 	g_free(gp);
-}				// _qq_send_again
+}
 
-/*****************************************************************************/
-// packet lost, do not send again
-static void _qq_send_cancel(gc_and_packet * gp)
+/* packet lost, do not send again */
+static void _qq_send_cancel(gc_and_packet *gp)
 {
 	GaimConnection *gc;
 	qq_data *qd;
@@ -129,9 +123,8 @@
 		qq_sendqueue_remove(qd, packet->send_seq);
 
 	g_free(gp);
-}				// _qq_send_cancel
+}
 
-/*****************************************************************************/
 gboolean qq_sendqueue_timeout_callback(gpointer data)
 {
 	GaimConnection *gc;
@@ -148,37 +141,38 @@
 	now = time(NULL);
 	list = qd->sendqueue;
 
-	// empty queue, return TRUE so that timeout continues functioning
+	/* empty queue, return TRUE so that timeout continues functioning */
 	if (qd->sendqueue == NULL)
 		return TRUE;
 
-	while (list != NULL) {	// remove all packet whose resend_times == -1
+	while (list != NULL) {	/* remove all packet whose resend_times == -1 */
 		p = (qq_sendpacket *) list->data;
-		if (p->resend_times == -1) {	// to remove
+		if (p->resend_times == -1) {	/* to remove */
 			qd->sendqueue = g_list_remove(qd->sendqueue, p);
 			g_free(p->buf);
 			g_free(p);
 			list = qd->sendqueue;
-		} else
+		} else {
 			list = list->next;
-	}			// while list
+		}
+	}
 
 	list = qd->sendqueue;
 	while (list != NULL) {
 		p = (qq_sendpacket *) list->data;
 		if (p->resend_times >= QQ_RESEND_MAX) {
-			if (p->resend_times == QQ_RESEND_MAX) {	// reach max
+			if (p->resend_times == QQ_RESEND_MAX) {	/* reach max */
 				switch (p->cmd) {
 				case QQ_CMD_KEEP_ALIVE:
 					if (qd->logged_in) {
 						gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Connection lost!\n");
 						gaim_connection_error(gc, _("Connection lost!"));
 						qd->logged_in = FALSE;
-					}	// if logged_in
+					}
 					p->resend_times = -1;
 					break;
 				case QQ_CMD_LOGIN:
-					if (!qd->logged_in)	// cancel logging progress
+					if (!qd->logged_in)	/* cancel logging progress */
 						gaim_connection_error(gc, _("Login failed, no reply!"));
 					p->resend_times = -1;
 					break;
@@ -191,8 +185,8 @@
 						need_action =
 						    gaim_prefs_get_bool("/plugins/prpl/qq/prompt_for_missing_packet");
 						if (!need_action)
-							p->resend_times = -1;	// it will be removed next time
-						else {	// prompt for action
+							p->resend_times = -1;	/* it will be removed next time */
+						else {	/* prompt for action */
 							gp = g_new0(gc_and_packet, 1);
 							gp->gc = gc;
 							gp->packet = p;
@@ -207,24 +201,23 @@
 							     G_CALLBACK
 							     (_qq_send_again),
 							     _("Cancel"), G_CALLBACK(_qq_send_cancel));
-							p->resend_times++;	// will send once more, but only once
-						}	// if !need_action
-					}	// default
-				}	// switch
-			}	// resend_times == QQ_RESEND_MAX
-		} else {	// resend_times < QQ_RESEND_MAX, so sent it again
+							/* will send once more, but only once */
+							p->resend_times++;
+						}
+					}
+				}
+			}
+		} else {	/* resend_times < QQ_RESEND_MAX, so sent it again */
 			wait_time = (gint) (QQ_SENDQUEUE_TIMEOUT / 1000);
 			if (difftime(now, p->sendtime) > (wait_time * (p->resend_times + 1))) {
 				qq_proxy_write(qd, p->buf, p->len);
 				p->resend_times++;
 				gaim_debug(GAIM_DEBUG_INFO,
-					   "QQ", "<<< [%05d] send again for %d times!\n", p->send_seq, p->resend_times);
-			}	// if difftime
-		}		// if resend_times >= QQ_RESEND_MAX            
+					   "QQ", "<<< [%05d] send again for %d times!\n", 
+					   p->send_seq, p->resend_times);
+			}
+		}
 		list = list->next;
-	}			// whiile list
-	return TRUE;		// if we return FALSE, the timeout callback stops functioning
-}				// qq_sendqueue_timeout_callback
-
-/*****************************************************************************/
-// END OF FILE
+	}
+	return TRUE;		/* if we return FALSE, the timeout callback stops functioning */
+}