configure: update SSL check for libpurple 3.x.x
[siplcs.git] / src / miranda / miranda-connection.c
blob719c76b64aafba2acd7bddc2aef2c4cf75222c10
1 /**
2 * @file miranda-connection.c
4 * pidgin-sipe
6 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <windows.h>
24 #include <stdio.h>
25 #include <glib.h>
27 #include "sipe-backend.h"
28 #include "sipe-core.h"
30 #include "newpluginapi.h"
31 #include "m_protosvc.h"
32 #include "m_protoint.h"
33 #include "miranda-private.h"
35 void sipe_miranda_connection_destroy(SIPPROTO *pr)
37 int oldStatus;
39 SIPE_DEBUG_INFO("valid <%d> state <%d>", pr->valid, pr->state);
40 if (!pr->valid) return;
42 set_buddies_offline(pr);
43 sipe_miranda_close(pr);
44 pr->state = SIPE_MIRANDA_DISCONNECTED;
45 pr->valid = FALSE;
47 oldStatus = pr->proto.m_iStatus;
48 pr->proto.m_iDesiredStatus = ID_STATUS_OFFLINE;
49 pr->proto.m_iStatus = pr->proto.m_iDesiredStatus;
50 sipe_miranda_SendBroadcast(pr, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, pr->proto.m_iStatus);
53 static void disconnect_cb(SIPPROTO *pr)
55 SIPE_DEBUG_INFO_NOFORMAT("");
56 if (!pr->valid) return;
57 if (pr->state == SIPE_MIRANDA_DISCONNECTED) return;
58 pr->disconnecting = TRUE;
59 sipe_miranda_connection_destroy(pr);
60 pr->valid = FALSE;
61 pr->disconnecting = FALSE;
62 pr->disconnect_timeout = NULL;
65 void sipe_miranda_connection_error_reason(SIPPROTO *pr, sipe_connection_error error, const gchar *msg)
67 if (!pr->disconnect_timeout)
69 SIPE_DEBUG_INFO("valid <%d> state <%d> error <%d> message <%s>", pr->valid, pr->state, error, msg);
70 pr->disconnect_timeout = sipe_miranda_schedule_mseconds(disconnect_cb, 1000, pr);
74 void sipe_backend_connection_completed(struct sipe_core_public *sipe_public)
76 SIPPROTO *pr = sipe_public->backend_private;
77 int oldStatus = pr->proto.m_iStatus;
78 pr->state = SIPE_MIRANDA_CONNECTED;
79 pr->proto.m_iStatus = pr->proto.m_iDesiredStatus;
80 sipe_miranda_SendBroadcast(pr, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, pr->proto.m_iStatus);
83 void sipe_backend_connection_error(struct sipe_core_public *sipe_public,
84 sipe_connection_error error,
85 const gchar *msg)
87 SIPE_DEBUG_INFO("reason <%d> message <%s>", error, msg);
88 sipe_miranda_connection_error_reason(sipe_public->backend_private, error, msg);
91 gboolean sipe_backend_connection_is_disconnecting(struct sipe_core_public *sipe_public)
93 SIPPROTO *pr = sipe_public->backend_private;
94 return (pr->disconnecting);
97 gboolean sipe_backend_connection_is_valid(struct sipe_core_public *sipe_public)
99 SIPPROTO *pr = sipe_public->backend_private;
100 return (pr->state == SIPE_MIRANDA_CONNECTED);
104 Local Variables:
105 mode: c
106 c-file-style: "bsd"
107 indent-tabs-mode: t
108 tab-width: 8
109 End: