Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

MyMinionSocket Class Reference

#include <MyMinionSocket.h>

List of all members.

Public Member Functions

 MyMinionSocket (SocketHandler &)
 MyMinionSocket (SocketHandler &, const std::string &, ipaddr_t, port_t)
 ~MyMinionSocket ()
ICrypt * AllocateCrypt ()
int GetMaxConnections ()
unsigned char * GetKey_m2minion ()
void Notify (const std::string &str)
bool OnVerifiedLine (const std::string &cmd, Parse &pa)
void OnConnect ()
void OnAccept ()


Detailed Description

File ......... MyMinionSocket.h Published .... 2004-04-19

Definition at line 30 of file MyMinionSocket.h.


Constructor & Destructor Documentation

MyMinionSocket::MyMinionSocket SocketHandler &   ) 
 

Definition at line 48 of file MyMinionSocket.cpp.

References MyMinionSocket().

Referenced by MyMinionSocket().

00049 :MinionSocket(h) 00050 { 00051 }

MyMinionSocket::MyMinionSocket SocketHandler &  ,
const std::string &  ,
ipaddr_t  ,
port_t 
 

Definition at line 54 of file MyMinionSocket.cpp.

References MyMinionSocket().

00055 :MinionSocket(h,s,a,p) 00056 { 00057 }

MyMinionSocket::~MyMinionSocket  ) 
 

Definition at line 60 of file MyMinionSocket.cpp.

00061 { 00062 }


Member Function Documentation

ICrypt* MyMinionSocket::AllocateCrypt  )  [inline]
 

Definition at line 37 of file MyMinionSocket.h.

00037 { return new NullCrypt; }

unsigned char* MyMinionSocket::GetKey_m2minion  )  [inline]
 

Definition at line 39 of file MyMinionSocket.h.

00039 { return static_cast<FinderHandler&>(Handler()).GetKey_m2minion(); }

int MyMinionSocket::GetMaxConnections  )  [inline]
 

Definition at line 38 of file MyMinionSocket.h.

00038 { return 3; }

void MyMinionSocket::Notify const std::string &  str  )  [inline]
 

Definition at line 41 of file MyMinionSocket.h.

References Notify().

Referenced by Notify().

00041 { 00042 // printf("%s\n",str.c_str()); 00043 Handler().LogError(this, "Notify", 0, str.c_str()); 00044 }

void MyMinionSocket::OnAccept  ) 
 

Definition at line 152 of file MyMinionSocket.cpp.

References g_app, and MyApp::ShowBalloonTip().

00153 { 00154 MinionSocket::OnAccept(); 00155 std::string remote = this->GetRemoteHostname(); 00156 std::string remote_ip = this->GetRemoteAddress(); 00157 g_app->ShowBalloonTip("Minion", "Incoming connection from " + remote + " (" + remote_ip + ")"); 00158 }

void MyMinionSocket::OnConnect  ) 
 

Definition at line 143 of file MyMinionSocket.cpp.

References g_app, and MyApp::ShowBalloonTip().

00144 { 00145 MinionSocket::OnConnect(); 00146 std::string remote = this->GetRemoteHostname(); 00147 std::string remote_ip = this->GetRemoteAddress(); 00148 g_app->ShowBalloonTip("Minion", "Connected to " + remote + " (" + remote_ip + ")"); 00149 }

bool MyMinionSocket::OnVerifiedLine const std::string &  cmd,
Parse &  pa
 

Definition at line 65 of file MyMinionSocket.cpp.

References db::Item::category, D2, db::Item::data, g_app, FinderHandler::GetDatabase(), db::Linkitemtag::item, db::Tag::name, db::Item::name, db::Category::name, db::Tag::num, db::Item::num, db::Category::num, OnVerifiedLine(), db::Linkitemtag::save(), db::Tag::save(), db::Item::save(), db::Category::save(), db::Item::sha1, MyApp::ShowBalloonTip(), db::Item::sz, db::Linkitemtag::tag, and db::Item::typ.

Referenced by OnVerifiedLine().

00066 { 00067 FinderHandler& h = static_cast<FinderHandler&>(Handler()); 00068 Database& db = h.GetDatabase(); 00069 00070 D2(fprintf(fil,"MyMinionSocket verified command: %s\n",cmd.c_str());) 00071 00072 // 'post' _ typ : 64(category) : 64(tag) : 64(tag) : 64(tag) : 64(name) : data(64) : sz : sha1 00073 if (cmd == "post") 00074 { 00075 Query q(db); 00076 char sql[1000]; 00077 00078 std::string typ = pa.getword(); 00079 D2(fprintf(fil," post.typ == '%s'\n",typ.c_str());) 00080 if (typ != "File" && typ != "URL") 00081 { 00082 return true; 00083 } 00084 std::string strCategory = Utility::base64d(pa.getword()); 00085 /* 00086 std::string strTag1 = Utility::base64d(pa.getword()); 00087 std::string strTag2 = Utility::base64d(pa.getword()); 00088 std::string strTag3 = Utility::base64d(pa.getword()); 00089 */ 00090 std::string strName = Utility::base64d(pa.getword()); 00091 std::string strData = pa.getword(); 00092 size_t sz = pa.getvalue(); 00093 std::string strSha1 = pa.getword(); 00094 D2(fprintf(fil, 00095 "category: %s\n" 00096 "name: %s\n" 00097 "data: %s\n" 00098 "size: %d\n" 00099 "sha1: %s\n", strCategory.c_str(), 00100 strName.c_str(), strData.c_str(), sz, strSha1.c_str());) 00101 00102 sprintf(sql,"select * from category where name='%s'", q.safestr(strCategory).c_str()); 00103 db::Category cat(&db, sql); 00104 cat.name = strCategory; 00105 cat.save(); 00106 00107 db::Item item(db, sz, strSha1); 00108 item.typ = typ; 00109 item.category = cat.num; 00110 item.name = strName; 00111 item.data.push_back( strData ); 00112 item.sz = sz; 00113 item.sha1 = strSha1; 00114 item.save(); 00115 00116 g_app->ShowBalloonTip("Minion", cat.name + ": " + item.name); 00117 00118 std::string strTag = pa.getword(); 00119 while (strTag.size()) 00120 { 00121 std::string tmp = Utility::base64d(strTag); 00122 sprintf(sql,"select * from tag where name='%s'", q.safestr(tmp).c_str()); 00123 db::Tag tag(&db, sql); 00124 tag.name = tmp; 00125 tag.save(); 00126 db::Linkitemtag x(db, item.num, tag.num); 00127 x.item = item.num; 00128 x.tag = tag.num; 00129 x.save(); 00130 // 00131 strTag = pa.getword(); 00132 } 00133 00134 } 00135 else 00136 { 00137 return MinionSocket::OnVerifiedLine(cmd, pa); 00138 } 00139 return true; 00140 }


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:42:41 2005 for Distributed URL Classification Tool by doxygen 1.3.7