00001 /* 00002 * GetAttributes.cpp 00003 * 00004 * Created on: 22.05.2011 00005 * Author: nick 00006 */ 00007 00008 #include <errno.h> 00009 00010 #include "GetAttributes.h" 00011 00012 void GetAttributes::handleTag(TagIQ &tag){ 00013 //ServerConfig *sc=ServerConfig::getInstance(); 00014 //std::cout<<"Read Dir IQ Handler from:"<<rd.getPath()<<endl; 00015 if(tag.getType()==TagIQ::Get){ 00016 GetAttr attr(tag);//= new ReadDir(tag); 00017 //Путь по которому надо получить файлы 00018 //const char* dpath=("/home/nick/"+attr.getPath()).c_str(); 00019 string dpath=sc->getSharedDir()+attr.getPath(); 00020 //const char* dpath=(sc->getSharedDir()+attr.getPath()).c_str(); 00021 struct stat buf; 00022 GetAttr rdresp(protocol->getCurNodeSend() ,"server",attr.getFrom(),TagIQ::Result,attr.getID()); 00023 memset(&buf,0,sizeof(buf)); 00024 if (stat(dpath.c_str(), &buf)<0){ 00025 rdresp.setError(errno); 00026 cout<<"ОШИБКА ПОЛУЧЕНИЯ АТРИБУТОВ ФАЙЛА!!!"<<dpath<<endl; 00027 }else{ 00028 rdresp.setFileInfo(buf/*buf.st_mode,buf.st_nlink,buf.st_size*/); 00029 } 00030 protocol->sendNode(rdresp); 00031 } 00032 } 00033 00034 //Тут надо подумать возможно это стоит вынести в отдельный класс, т.к. повторится на каждом теге 00035 GetAttributes::GetAttributes(Protocol &protocol,ServerConfig* sc) { 00036 // TODO Auto-generated constructor stub 00037 this->sc=sc; 00038 this->protocol=&protocol; 00039 protocol.addIQHandler(this,GetAttr_xmlnsData); 00040 } 00041 00042 GetAttributes::~GetAttributes() { 00043 // TODO Auto-generated destructor stub 00044 cout<<"2.1 шаг уд"<<endl; 00045 this->protocol->removeIQHandler(this); 00046 cout<<"2.2 шаг уд"<<endl; 00047 }
1.7.1