void ProfileView::fileCustomPopupMenu( QPoint /*point*/ ) { QMenu contextMnu( this ); QAction *downloadAct = NULL; QAction *downloadAllAct = NULL; QAction *removeAct = NULL; QAction *clearAct = NULL; if (mIsOwnId) { removeAct = new QAction( tr( "Remove Favourite" ), this ); clearAct = new QAction( tr( "Clear Favourites" ), this ); connect( removeAct , SIGNAL( triggered() ), this, SLOT( fileRemove() ) ); connect( clearAct , SIGNAL( triggered() ), this, SLOT( filesClear() ) ); contextMnu.addAction( clearAct ); contextMnu.addAction( removeAct ); } else { downloadAct = new QAction( tr( "Download File" ), this ); downloadAllAct = new QAction( tr( "Download All" ), this ); connect( downloadAct , SIGNAL( triggered() ), this, SLOT( fileDownload() ) ); connect( downloadAllAct , SIGNAL( triggered() ), this, SLOT( filesDownloadAll() ) ); contextMnu.addAction( downloadAct ); contextMnu.addAction( downloadAllAct ); } contextMnu.exec(QCursor::pos()); }
//deal with download command, and call fileDownload to download a file from server void Download(const uchar *str, int socket) { uchar cpyStr[MAXLEN_CMD]; uchar fileName[20]; uchar buffer[BUFSIZE]; ssize_t RecvBytes; bzero(buffer,BUFSIZE); bzero(fileName,20); strcpy(cpyStr,str); strtok(cpyStr," \n"); strcpy(fileName,strtok(NULL," \n")); //Send(socket,str,BUFSIZE,0); send_message(str,strlen(str),'1', socket); fileDownload(fileName, socket); }