00001 #ifndef CHAT_CONNECTION_IMPLEMENTATION_FILE 00002 #define CHAT_CONNECTION_IMPLEMENTATION_FILE 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : chat_connection * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2000-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "chat_connection.h" 00019 00020 #include <basis/istring.h> 00021 #include <opsystem/filename.h> 00022 00024 00025 //not a transport; make it based on cromp. 00026 /* 00027 class buzz_transport : public transport 00028 { 00029 public: 00030 buzz_transport(chat_connection &parent, communicator &commlink, 00031 extended_address &where); 00032 00033 ~buzz_transport() {} 00034 00035 virtual void event_hook(long event); 00036 00037 private: 00038 chat_connection &_parent; // the manager of this object. 00039 }; 00040 00042 00043 buzz_transport::buzz_transport(chat_connection &parent, communicator &commlink, 00044 extended_address &where) 00045 : _parent(parent), 00046 transport(commlink) 00047 { 00048 } 00049 00050 void buzz_transport::event_hook(long event) 00051 { 00052 } 00053 */ 00054 00056 00057 00058 /* 00059 enum chat_capabilities { 00060 SEND_TEXT = 0x1, // all chat connections should support this. 00061 SEND_FILE = 0x2, // many chat connections can support this. if initially 00062 // it is not supported, try using the renegotiate() 00063 // method to get the other side to allow it. 00064 }; 00065 00066 enum outcomes { 00067 OKAY, // everything worked as expected. 00068 NO_CONNECTION, // the connection has dropped or was never established. 00069 NO_CAPABILITY, // the connection doesn't support this currently. 00070 }; 00071 */ 00072 00073 /* 00074 chat_connection::chat_connection(communicator &commlink, 00075 const extended_address &where, int capabilities) 00076 : _sender(NIL), 00077 _receiver(NIL) 00078 { 00079 extended_address patched = where; 00080 //hmmm: what about patching the port to be well-known? not yet. 00081 patched.entity(transport::CLIENT); 00082 _sender = new buzz_transport(*this, commlink, patched); 00083 patched.entity(transport::SERVER); 00084 patched.mode(patched.mode() | transport::AUTO_SOURCE); 00085 _sender = new buzz_transport(*this, commlink, patched); 00086 } 00087 00088 chat_connection::~chat_connection() 00089 { 00090 WHACK(_sender); 00091 WHACK(_receiver); 00092 } 00093 00094 // no implementation for base class. 00095 void chat_connection::renegotiation() {} 00096 void chat_connection::data_ready() {} 00097 00098 const char *chat_connection::outcome_name(const outcome &outcome) const 00099 { 00100 switch (outcome.value()) { 00101 case NO_CAPABILITY: return "NO_CAPABILITY"; 00102 default: return communication_commons::outcome_name(outcome); 00103 } 00104 } 00105 00106 //uuhhhh.... problems... multiple clients.... 00107 bool chat_connection::connected() const { return _sender->connected(); } 00108 00109 filename chat_connection::download_path() const 00110 { 00111 return ""; 00112 } 00113 00114 void chat_connection::download_path(const filename &path) 00115 { 00116 } 00117 00118 int chat_connection::capabilities() const 00119 { 00120 return 0; 00121 } 00122 00123 void chat_connection::capabilities(int new_capabilities) 00124 { 00125 } 00126 00127 outcome chat_connection::renegotiate(int new_capability) 00128 { 00129 return NO_CONNECTION; 00130 } 00131 00132 outcome chat_connection::send_string(const istring &to_send) 00133 { 00134 return NO_CONNECTION; 00135 } 00136 00137 outcome chat_connection::send_file(const istring &filename) 00138 { 00139 return NO_CONNECTION; 00140 } 00141 00142 bool chat_connection::get_string(istring &received) 00143 { 00144 return false; 00145 } 00146 00147 bool chat_connection::get_file(istring &path) 00148 { 00149 return false; 00150 } 00151 */ 00152 00153 00154 #endif //CHAT_CONNECTION_IMPLEMENTATION_FILE 00155
1.5.1