Port things from MSN to WLM plugin:
[kdenetwork.git] / kopete / protocols / wlm / wlmsocket.cpp
blob3afa76196797e7532ea7b322221b1499f0cfe515
1 /*
2 wlmsocket.cpp - Kopete Wlm Protocol
4 Copyright (c) 2008 by Tiago Salem Herrmann <tiagosh@gmail.com>
5 Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
8 * *
9 * This library is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU General Public *
11 * License as published by the Free Software Foundation; either *
12 * version 2 of the License, or (at your option) any later version. *
13 * *
14 *************************************************************************
17 #include "wlmsocket.h"
19 #include <QObject>
21 WlmSocket::WlmSocket (MSN::NotificationServerConnection * mainConnection, bool isSSL) :
22 m_isSSL(isSSL)
24 main = false;
25 this->mainConnection = mainConnection;
27 QObject::connect (this, SIGNAL (connected ()), this,
28 SLOT (connectionReady ()));
29 QObject::connect (this, SIGNAL (disconnected ()), this,
30 SLOT (connectionFinished ()));
31 QObject::connect (this, SIGNAL (encrypted ()), this,
32 SLOT (connectionEncryptedReady()));
36 void
37 WlmSocket::connectionEncryptedReady()
39 MSN::Connection * c;
41 if (!mainConnection)
42 return;
43 // Retrieve the connection associated with the
44 // socket's file handle on which the event has
45 // occurred.
46 c = mainConnection->connectionWithSocket ((void*)this);
48 // if this is a libmsn socket
49 if (c != NULL)
51 if (c->isConnected () == false)
53 c->socketConnectionCompleted ();
55 // If this event is due to new data becoming available
56 c->socketIsWritable ();
61 void
62 WlmSocket::connectionReady ()
64 MSN::Connection * c;
66 // ssl is connected when encrypted() is raised
67 if(isSSL())
68 return;
70 if (!mainConnection)
71 return;
72 // Retrieve the connection associated with the
73 // socket's file handle on which the event has
74 // occurred.
75 c = mainConnection->connectionWithSocket ((void*)this);
77 // if this is a libmsn socket
78 if (c != NULL)
80 if (c->isConnected () == false)
82 c->socketConnectionCompleted ();
84 // If this event is due to new data becoming available
85 c->socketIsWritable ();
89 void
90 WlmSocket::connectionFinished ()
94 void
95 WlmSocket::incomingData ()
97 MSN::Connection * c;
99 if (!mainConnection)
100 return;
102 // Retrieve the connection associated with the
103 // socket's file handle on which the event has
104 // occurred.
105 c = mainConnection->connectionWithSocket ((void*)this);
107 // if this is a libmsn socket
108 if (c != NULL)
110 if (c->isConnected () == false)
112 c->socketConnectionCompleted ();
114 // If this event is due to new data becoming available
115 c->dataArrivedOnSocket ();
119 WlmSocket::~WlmSocket ()
123 #include "wlmsocket.moc"