/usr/include/msn/connection.h is in libmsn-dev 4.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #ifndef __msn_connection_h__
#define __msn_connection_h__
/*
* connection.h
* libmsn
*
* Created by Mark Rowe on Mon Mar 22 2004.
* Refactored by Tiago Salem Herrmann on 08/2007.
* Copyright (c) 2004 Mark Rowe. All rights reserved.
* Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string>
#include <list>
#include <vector>
#include <map>
#include <stdexcept>
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
#include "libmsn_export.h"
namespace MSN
{
class callback;
class Message;
class Passport;
class NotificationServerConnection;
/** An abstract base class that represents a connection to another computer.
*
* Connection provides an interface and some functionality that is common
* to notification, switchboard and file transfer connections.
*
*/
class LIBMSN_EXPORT Connection
{
public:
/** The socket which connects this Connection to another computer
*
* @deprecated In the future, this member will be made private. Any
* functions that access this member should be converted to
* member functions of a subclass.
*/
void *sock;
/** Indicates whether a connection has been established.
*/
bool connected;
protected:
std::string readBuffer;
public:
/** The transaction ID of the next command to be sent.
*/
int trID;
Connection();
virtual ~Connection();
/** Dispatch a command to its appropriate handler routines based on @a args.
*
* @param args A vector of strings containing arguments, returned from readLine.
*/
virtual void dispatchCommand(std::vector<std::string> & args) = 0;
/** Read a line from the network and split it into its components.
*
* MSN commands and their arguments are separated by white space.
*/
std::vector<std::string> getLine();
bool isWholeLineAvailable();
bool bytesAvailable();
/** Write a string to the connection.
*
*/
virtual size_t write(std::string s, bool log=true) throw (std::runtime_error);
/** Write the contents of a stringstream to the connection.
*
* @param s The stringstream to write.
* @param log Should we log this output to the console.
*
* write will buffer the output if a connection has not yet been established.
* In this case, the data will be written as soon as a connection is
* established.
*/
virtual size_t write(std::ostringstream & s, bool log=true) throw (std::runtime_error);
/** Connect ourself to @a hostname on @a port.
*/
virtual void connect(const std::string & hostname, unsigned int port) = 0;
virtual void disconnect() = 0;
/** @name External Socket Hooks
*
* These members should be called whenever an appropriate socket event
* occurs.
*/
/** @{ */
/** New data is available on the connection.
*/
virtual void dataArrivedOnSocket();
/** The connection has been established.
*/
virtual void socketConnectionCompleted();
virtual void socketIsWritable() {};
/** An error has occurred on the socket.
*/
virtual void errorOnSocket(int errno_);
/** @} */
/** Notify the calling library that an error with code @a errorCode has
* occured.
*/
void showError(int errorCode);
/** Is this Connection connected to a remote endpoint?
*/
bool isConnected() { return this->connected; };
virtual NotificationServerConnection *myNotificationServer() = 0;
protected:
virtual void handleIncomingData() = 0;
private:
std::string writeBuffer;
};
}
#endif
|