sign: fix protocol name for TLS-DSK
[siplcs.git] / src / miranda / miranda-connection.c
blob8058e2ef63cbf4c6bb67b9d3215e8aa6b564a85a
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 void sipe_miranda_connection_error_reason(SIPPROTO *pr, sipe_connection_error error, const gchar *msg)
55 SIPE_DEBUG_INFO("valid <%d> state <%d> error <%d> message <%s>", pr->valid, pr->state, error, msg);
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;
65 void sipe_backend_connection_completed(struct sipe_core_public *sipe_public)
67 SIPPROTO *pr = sipe_public->backend_private;
68 int oldStatus = pr->proto.m_iStatus;
69 pr->state = SIPE_MIRANDA_CONNECTED;
70 pr->proto.m_iStatus = pr->proto.m_iDesiredStatus;
71 sipe_miranda_SendBroadcast(pr, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, pr->proto.m_iStatus);
74 void sipe_backend_connection_error(struct sipe_core_public *sipe_public,
75 sipe_connection_error error,
76 const gchar *msg)
78 SIPE_DEBUG_INFO("reason <%d> message <%s>", error, msg);
79 sipe_miranda_connection_error_reason(sipe_public->backend_private, error, msg);
82 gboolean sipe_backend_connection_is_disconnecting(struct sipe_core_public *sipe_public)
84 SIPPROTO *pr = sipe_public->backend_private;
85 return (pr->disconnecting);
88 gboolean sipe_backend_connection_is_valid(struct sipe_core_public *sipe_public)
90 SIPPROTO *pr = sipe_public->backend_private;
91 return (pr->state == SIPE_MIRANDA_CONNECTED);
95 Local Variables:
96 mode: c
97 c-file-style: "bsd"
98 indent-tabs-mode: t
99 tab-width: 8
100 End: