Example #1
0
int main(int argc, char **argv)
{
    /* Mainly only for safety */
    setupSignal();
    
    /* Initialize decoder's */
    DecoderSet(dInstr);
    
    banner(argc,argv);
    
    if( (u2AnonContext = parseCommandLine(argc,argv)) == NULL)
    {
	/* XXX */
	CleanExit(1);
    }
    
    if(u2AnonContext->verbose_flag)
    {
	printContext(u2AnonContext);
    }

    if( fileOperation(u2AnonContext))
    {
	/* XXX */
	CleanExit(1);
    }
    
    
    CleanExit(0); 
    /* Exit here but remove the compile warn ...*/
    return 0;
}
void MainWindow::submitPath() {

    QString Path1 = inputPath -> text();
    QString Path2 = outputPath -> text();
    string Path3 = Path1.toStdString();
    string Path4 = Path2.toStdString();
    const char *inPath = Path3.c_str();
    const char *outPath = Path4.c_str();
    fileOperation(inPath,outPath);

}
Example #3
0
void lmcMessageLog::log_linkClicked(QUrl url) {
	QString linkPath = url.toString();

	//	this is a hack so qdesktopservices can open a network path
	if(linkPath.startsWith("file")) {
		// strip out the 'file:' prefix and get the path
		linkPath = linkPath.mid(5);
		// use a url that contains native separators
		QDesktopServices::openUrl(QUrl(QDir::toNativeSeparators(linkPath)));
		return;
	} else if(linkPath.startsWith("www")) {
		// prepend 'http://' to link
		linkPath.prepend("http://");
		QDesktopServices::openUrl(QUrl(linkPath));
		return;
	} else if(!linkPath.startsWith("lmc")) {
		QDesktopServices::openUrl(url);
		return;
	}

	QStringList linkData = linkPath.split("/", QString::SkipEmptyParts);
	FileMode mode;
	FileOp op;

	if(linkData[1].compare("fileaccept", Qt::CaseInsensitive) == 0) {
		mode = FM_Receive;
		op = FO_Accept;
	} else if(linkData[1].compare("filedecline", Qt::CaseInsensitive) == 0) {
		mode = FM_Receive;
		op = FO_Decline;
	} else if(linkData[1].compare("filecancel", Qt::CaseInsensitive) == 0) {
		mode = FM_Send;
		op = FO_Cancel;
	} else	// unknown link command
		return;

	//	Remove the link and show a confirmation message.
	updateFileMessage(mode, op, linkData[2]);

	fileOperation(linkData[2], linkData[1]);
}
Example #4
0
// This function is called to display a file request message on chat box
void lmcMessageLog::appendFileMessage(MessageType type, QString* lpszUserName, XmlMessage* pMessage,
									  bool bReload) {
	QString htmlMsg;
	QString caption;
	QString fileId = pMessage->data(XN_FILEID);
	QString tempId;
	QString szStatus;

	htmlMsg = themeData.reqMsg;
	htmlMsg.replace("%iconpath%", "qrc"IDR_FILEMSG);

    FileOp fileOp = (FileOp) Helper::indexOf(FileOpNames, FO_Max, pMessage->data(XN_FILEOP));

	if(type == MT_LocalFile) {
		tempId = "send" + fileId;
		caption = tr("Sending '%1' to %2.");
		htmlMsg.replace("%sender%", caption.arg(pMessage->data(XN_FILENAME), *lpszUserName));
		htmlMsg.replace("%message%", "");
		htmlMsg.replace("%fileid%", tempId);

		switch(fileOp) {
		case FO_Request:
			sendFileMap.insert(fileId, *pMessage);
			pMessage->addData(XN_TEMPID, tempId);

			htmlMsg.replace("%links%", "<a href='lmc://filecancel/" + fileId + "'>" + tr("Cancel") + "</a>");
			break;
		case FO_Cancel:
		case FO_Accept:
		case FO_Decline:
			szStatus = getFileStatusMessage(FM_Send, fileOp);
			htmlMsg.replace("%links%", szStatus);
			break;
		default:
			return;
			break;
		}
	} else if(type == MT_File) {
		tempId = "receive" + fileId;
		if(autoFile) {
			caption = tr("%1 is sending you a file:");
			htmlMsg.replace("%sender%", caption.arg(*lpszUserName));
			htmlMsg.replace("%message%", pMessage->data(XN_FILENAME) + " (" +
				Helper::formatSize(pMessage->data(XN_FILESIZE).toLongLong()) + ")");
			htmlMsg.replace("%fileid%", "");
		} else {
			caption = tr("%1 sends you a file:");
			htmlMsg.replace("%sender%", caption.arg(*lpszUserName));
			htmlMsg.replace("%message%", pMessage->data(XN_FILENAME) + " (" +
				Helper::formatSize(pMessage->data(XN_FILESIZE).toLongLong()) + ")");
			htmlMsg.replace("%fileid%", tempId);
		}

		switch(fileOp) {
		case FO_Request:
			receiveFileMap.insert(fileId, *pMessage);
			pMessage->addData(XN_TEMPID, tempId);

			if(autoFile) {
				htmlMsg.replace("%links%", tr("File has been accepted automatically."));
			} else {
				htmlMsg.replace("%links%", "<a href='lmc://fileaccept/" + fileId + "'>" + tr("Accept") + "</a>&nbsp;&nbsp;" +
					"<a href='lmc://filedecline/" + fileId + "'>" + tr("Decline") + "</a>");
			}

			if(autoFile && !bReload)
				fileOperation(fileId, "fileaccept");
			break;
		case FO_Cancel:
		case FO_Accept:
		case FO_Decline:
			szStatus = getFileStatusMessage(FM_Receive, fileOp);
			htmlMsg.replace("%links%", szStatus);
			break;
		default:
			return;
			break;
		}
	}

	QWebFrame* frame = page()->mainFrame();
	QWebElement document = frame->documentElement();
	QWebElement body = document.findFirst("body");
	body.appendInside(htmlMsg);
}
Example #5
0
// This function is called to display a file request message on chat box
void wavrMessageLog::appendFileMessage(MessageType type, QString* lpszUserName, wavrXmlMessage* pMessage,
                                      bool bReload) {
    Q_UNUSED(type);
    QString htmlMsg;
    QString caption;
    QString fileId = pMessage->data(XML_FILEID);
    QString tempId;
    QString szStatus;
    QString fileType;

    switch(type) {
    case MT_File:
        fileType = "file";
        break;
    case MT_Folder:
        fileType = "folder";
        break;
    default:
        return;
        break;
    }

    htmlMsg = themeData.reqMsg;
    htmlMsg.replace("%iconpath%", "qrc"IDR_FILEMSG);

    FileOp fileOp = (FileOp)wavrHelper::indexOf(FileOpNames, FO_Max, pMessage->data(XML_FILEOP));
    FileMode fileMode = (FileMode)wavrHelper::indexOf(FileModeNames, FM_Max, pMessage->data(XML_MODE));

    if(fileMode == FM_Send) {
        qDebug() << "inside fmsend message";
        tempId = "send" + fileId;
        caption = tr("Sending '%1' to %2.");
        htmlMsg.replace("%sender%", caption.arg(pMessage->data(XML_FILENAME), *lpszUserName));
        htmlMsg.replace("%message%", "");
        htmlMsg.replace("%fileid%", tempId);

        switch(fileOp) {
        case FO_Request:
            sendFileMap.insert(fileId, *pMessage);
            pMessage->addData(XML_TEMPID, tempId);
            htmlMsg.replace("%links%", "<a href='wavr://" + fileType + "/" + cancelOp + "/" + fileId + "'>" + tr("Cancel") + "</a>");
            break;
        case FO_Cancel:
        case FO_Accept:
        case FO_Decline:
        case FO_Error:
        case FO_Abort:
        case FO_Complete:
            szStatus = getFileStatusMessage(FM_Send, fileOp);
            htmlMsg.replace("%links%", szStatus);
            break;
        default:
            return;
            break;
        }
    } else {
        tempId = "receive" + fileId;
        if(autoFile) {
            if(type == MT_File)
                caption = tr("%1 is sending you a file:");
            else
                caption = tr("%1 is sending you a folder:");
            htmlMsg.replace("%sender%", caption.arg(*lpszUserName));
            htmlMsg.replace("%message%", pMessage->data(XML_FILENAME) + " (" +
                wavrHelper::formatSize(pMessage->data(XML_FILESIZE).toLongLong()) + ")");
            htmlMsg.replace("%fileid%", "");
        } else {
            if(type == MT_File)
                caption = tr("%1 sends you a file:");
            else
                caption = tr("%1 sends you a folder:");
            htmlMsg.replace("%sender%", caption.arg(*lpszUserName));
            htmlMsg.replace("%message%", pMessage->data(XML_FILENAME) + " (" +
                wavrHelper::formatSize(pMessage->data(XML_FILESIZE).toLongLong()) + ")");
            htmlMsg.replace("%fileid%", tempId);
        }

        switch(fileOp) {
        case FO_Request:
            receiveFileMap.insert(fileId, *pMessage);
            pMessage->addData(XML_TEMPID, tempId);

            if(autoFile) {
                htmlMsg.replace("%links%", tr("Accepted"));
                if(!bReload)
                    fileOperation(fileId, acceptOp, fileType);
            } else {
                htmlMsg.replace("%links%",
                    "<a href='wavr://" + fileType + "/" + acceptOp + "/" + fileId + "'>" + tr("Accept") + "</a>&nbsp;&nbsp;" +
                    "<a href='wavr://" + fileType + "/" + declineOp + "/" + fileId + "'>" + tr("Decline") + "</a>");
            }
            break;
        case FO_Cancel:
        case FO_Accept:
        case FO_Decline:
        case FO_Error:
        case FO_Abort:
        case FO_Complete:
            szStatus = getFileStatusMessage(FM_Receive, fileOp);
            htmlMsg.replace("%links%", szStatus);
            break;
        default:
            return;
            break;
        }
    }

    QWebFrame* frame = page()->mainFrame();
    QWebElement document = frame->documentElement();
    QWebElement body = document.findFirst("body");
    body.appendInside(htmlMsg);
}