См. документацию.00001
00002
00003
00004
00005
00006
00007
00008 #include "ReadDirectory.h"
00009 #define debug_output
00010 void ReadDirectory::handleTag(TagIQ &tag){
00011 ReadDir rd(tag);
00012 #ifdef debug_output
00013 std::cout<<"Read Dir IQ Handler from:"<<rd.getPath()<<endl;
00014 #endif
00015 if(rd.getType()==TagIQ::Get){
00016 #ifdef debug_output
00017 std::cout<<"OK GET"<<endl;
00018 #endif
00019
00020
00021 string dpath=sc->getSharedDir()+rd.getPath();
00022 #ifdef debug_output
00023 std::cout<<"PATH GET ok"<<dpath<<endl;
00024 #endif
00025 DIR* d=opendir(dpath.c_str());
00026 #ifdef debug_output
00027 std::cout<<"oPENdIR ok"<<endl;
00028 #endif
00029 dirent* de=readdir(d);
00030
00031 #ifdef debug_output
00032 cout<<"READ DIR ok"<<endl;
00033 #endif
00034 ReadDir rdresp(protocol->getCurNodeSend() ,"server",rd.getFrom(),TagIQ::Result,rd.getID());
00035 #ifdef debug_output
00036 cout<<"MK RESP OK"<<endl;
00037 #endif
00038 while(de!=NULL){
00039 #ifdef debug_output
00040 cout<<"ADD FILENAME"<<endl;
00041 #endif
00042 rdresp.addFilename(de->d_name);
00043 #ifdef debug_output
00044 cout<<"ADD FILENAME OK"<<endl;
00045 #endif
00046
00047 de=readdir(d);
00048 #ifdef debug_output
00049 cout<<"READ DIR ok 2"<<endl;
00050 #endif
00051 }
00052 closedir(d);
00053 #ifdef debug_output
00054 std::cout<<"Read Dir send response:"<<endl;
00055 #endif
00056 protocol->sendNode(rdresp);
00058 #ifdef debug_output
00059 std::cout<<"Read Dir sended response:"<<endl;
00060 #endif
00061
00062
00063 }
00064
00065
00066 }
00067
00068 ReadDirectory::ReadDirectory(Protocol &protocol,ServerConfig* sc) {
00069
00070 #ifdef debug_output
00071 cout<<"=== ReaddDirectory ==="<<endl;
00072 #endif
00073 this->protocol=&protocol;
00074 this->sc=sc;
00075 protocol.addIQHandler(this,ReadDir_xmlns);
00076 }
00077 ReadDirectory::ReadDirectory(){
00078
00079 }
00080 ReadDirectory::~ReadDirectory() {
00081
00082 this->protocol->removeIQHandler(this);
00083 }