Пример #1
0
std::string Acl::getErrorRightsDescription(std::string errorIdentifier,
				      std::vector<std::string> &errorRights)
{
	std::string verboseDescription=
		Gettext(_("Unable to set the requested permissions for %1%. "
			  "The mail server's valid permissions are"
			  " restricted as follows:\n\n"))
				  <<
		Gettext::fromutf8(errorIdentifier);

	if (errorRights.size() > 0 && errorRights[0].size() > 0)
	{
		verboseDescription +=
			Gettext(_("Minimum permissions: %1%.\n"))
				<<
			Acl::getDescription(errorRights[0]);
	}

	std::string singleRights;

	std::vector<std::string>::iterator
		b=errorRights.begin(), e=errorRights.end();

	if (b != e)
		++b;

	while (b != e)
	{
		if (b->size() == 1)
		{
			singleRights += *b;
		}
		else
		{
			verboseDescription +=
				Gettext(_("\"%1%\" may be set only all together as a group.\n"))
					<<
				Acl::getDescription(*b);
		}
		++b;
	}

	if (singleRights.size() > 0)
		verboseDescription +=
			Gettext(_("\"%1%\" may be set in any combination.\n"))
				<<
			Acl::getDescription(singleRights);

	return verboseDescription;
}
Пример #2
0
void CertificatesScreen::Certificate::isused(std::string name)
{
	statusBar->clearstatus();
	statusBar->status(Gettext(_("This certificate is used by %1%"))
			  << name,
			  statusBar->SYSERROR);
	statusBar->beepError();
	mainScreen->draw();
}
Пример #3
0
main()
{
	int i,j;
	int num_of_line;
	char s[MAX][MAX];
	char text[MAX]={"i would like to ask you.\nif you will go with me.\ncould i?\nyes!\nbut you should make it quick!\nbecause i will leave.\n"};
	num_of_line=Gettext(text,s);
	for(i=0;i<=num_of_line;i++)
		for(j=0;s[i][j]!='\0';j++)
			printf("%c",s[i][j]);

}
Пример #4
0
//Connect to the olly/ida_sync server; prompts for connection info
void connect(void)
{
	//ensure a file is open for debugging
	if ( 0 == ((char *)Plugingetvalue(VAL_PROCESSNAME))[0])
	{
		MessageBox(hwmain,
				"Please open a file for debugging before connecting to an ida_sync server.",
				""PLUGIN_NAME"",MB_OK|MB_ICONSTOP);
		return;
	}

	// if we are already connected then to do nothing.
	if (connector->is_connected())
		return;

	int port  = 5041;
	char password    [256];

	if (-1 == Gettext("Server address:", coninfo->server_addr, 0x00, NM_NONAME, FIXEDFONT))
		return; //cancelled by user

	if (-1 == Gettext("Server port:", coninfo->portString, 0x00, NM_NONAME, FIXEDFONT))
		return; //cancelled by user
	port = atoi(coninfo->portString);

	if (-1 == Gettext("Username:"******"password");
	if (-1 == Gettext("Password:"******"", then set default project name
		strcpy(coninfo->project, (char *)Plugingetvalue(VAL_PROCESSNAME));
	if (-1 == Gettext("Project name:", coninfo->project, 0x00, NM_NONAME, FIXEDFONT))
		return; //cancelled by user

	connector->server_connect(coninfo->server_addr, port, 
		coninfo->username, password, coninfo->project);
}
Пример #5
0
Acl::Acl(std::string codeArg)
	: code(codeArg), descr(Gettext(_("Unknown permission \"%1%\""))
			       << codeArg)
{
#define DO(a,b) if (codeArg == a) descr=b;

	DO(ACL_LOOKUP, _("Visible"));
	DO(ACL_READ,_("Open"));
	DO(ACL_SEEN, _("Change read/unread status"));
	DO(ACL_WRITE, _("Change message status"));
	DO(ACL_INSERT, _("Insert messages"));
	DO(ACL_CREATE, _("Create subfolders"));
	DO(ACL_DELETEFOLDER, _("Delete folder"));
	DO(ACL_DELETEMSGS, _("Delete/undelete messages"));
	DO(ACL_EXPUNGE, _("Expunge deleted messages"));
	DO(ACL_ADMINISTER, _("Administrator"));
	DO(ACL_POST, _("Post messages to folder"));
#undef DO
}
Пример #6
0
//prompt user for name/label and push it out to the server
void insert_name(t_dump *pd)
{
	char buf [MAXSTR+128];
	char text [MAXSTR+128];

	if (connector->is_connected()) // && origin==PM_DISASM) --> do we need this?
	{
		Findname(pd->sel0,NM_LABEL,text); //get existing name
		if (-1 == Gettext("Enter "PLUGIN_NAME" label(name):", text, 0x00, NM_LABEL, FIXEDFONT))
			return; //cancelled by user
		Insertname(pd->sel0, NM_LABEL, text);
		Redrawdisassembler();
		sprintf(buf, "%d:::%08x:::%s", 
			IDA_SYNC_COMMAND_NAME, 
			pd->sel0, // our current selected address
			text);
		if (connector_push(buf))
			Message(pd->sel0, "[*] "PLUGIN_NAME"> Successfully pushed name/label at address 0x%08x to server.", pd->sel0);
	}//if connected
}
Пример #7
0
void CursesMessageDisplay::folderUpdated()
{
	std::string inProgress="----";

	CursesMessage *messageInfo=messageInfoPtr;

	if (!messageInfo)
		return;

	if (!messageInfo->reformatting()) // Reformat finished
	{
		size_t nLines=messageInfo->nLines();
		size_t h=getHeight();

		size_t lastLine= nLines > h ? nLines-h:0;

		std::string buffer;

		{
			std::ostringstream o;

			o << (lastLine == 0 ? 100
			      : getFirstLineShown() * 100 / lastLine);
			buffer=o.str();
		}
		buffer += "%";

		inProgress=buffer;
	}

	titleBar->setTitles(Gettext(_("%1%: %2% of %3% %4%"))
			    << messageInfo->myfolder->getFolder()->getName()
			    << messageInfo->messagesortednum+1
			    << messageInfo->myfolder->getServer()
			    ->server->getFolderIndexSize()
			    << (messageInfo->orig_status_code == 'N'
				? _(" (NEW)"):
				messageInfo->orig_status_code == 'D'
				? _(" (DELETED)"): ""),
			    inProgress);
}
Пример #8
0
bool Acl::EditScreen::EntryButton::processKeyInFocus(const Curses::Key &key)
{
	if (key == key_DELRIGHTS)
	{
		myServer::promptInfo prompt=
			myServer::promptInfo(Gettext(_("Remove permissions"
						       " for \"%1%\"?"
						       " (Y/N) "))
					     <<
					     Gettext::fromutf8(identifier))
			.yesno();

		prompt=myServer::prompt(prompt);

		if (prompt.abortflag ||
		    (std::string)prompt != "Y")
			return true;

		parent->deleteIdentifier(identifier);
		return true;
	}

	return CursesButton::processKeyInFocus(key);
}
void paimei_connect (void)
{
    hostent      *he;
    sockaddr_in  sin;
    in_addr      addr;
    WSADATA      wsa_data;

    char server[256];

    memset(server, 0, sizeof(server));
    strcpy(server, "127.0.0.1");

    // if we are already connected then to do nothing.
    if (connection)
        return;

    if (Gettext("PaiMei Server:", server, 0x00, NM_NONAME, FIXEDFONT) == -1)
        return;

    // initialize winsock.
    if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0)
    {
        olly_add_to_list(0, 1, "[!] "PLUGIN_NAME"> WSAStartup() failed.");
        return;
    }

    // confirm that the requested winsock version is supported.
    if (LOBYTE(wsa_data.wVersion) != 2 || HIBYTE(wsa_data.wVersion) != 2)
    {
        WSACleanup();
        olly_add_to_list(0, 1, PLUGIN_NAME"> Winsock version 2.2 not found.");
        return;
    }

    // if the provided server address is a hostname, then resolve it with gethostbyname().
    if (isalpha(server[0]))
    {
        if ((he = gethostbyname(server)) == NULL)
        {
            olly_add_to_list(0, 1, "[!] "PLUGIN_NAME"> Unable to resolve name: %s", server);
            return;
        }
    }
    // otherwise resolve the server address with gethostbyaddr().
    else
    {
        addr.s_addr = inet_addr(server);

        if ((he = gethostbyaddr((char *)&addr, sizeof(struct in_addr), AF_INET)) == NULL)
        {
            olly_add_to_list(0, 1, "[!] "PLUGIN_NAME"> Unable to resolve address");
            return;
        }
    }

    // create a socket.
    if ((connection = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)
    {
        WSACleanup();
        olly_add_to_list(0, 1, "[!] "PLUGIN_NAME"> Failed to create socket.");
        return;
    }

    // connect to the server.
    sin.sin_family = AF_INET;
    sin.sin_addr   = *((LPIN_ADDR)*he->h_addr_list);
    sin.sin_port   = htons(7033);

    if (connect(connection, (SOCKADDR *) &sin, sizeof(sin)) == SOCKET_ERROR)
    {
        WSACleanup();
        olly_add_to_list(0, 1, "[!] "PLUGIN_NAME"> Failed to connect to server.");
        return;
    }
}
Пример #10
0
bool CertificatesScreen::Certificate::processKeyInFocus(const Key &key)
{
	if (key == key_DELETECERTIFICATE)
	{
		std::vector<myServer *>::iterator b, e;

		for (b=myServer::server_list.begin(),
			     e=myServer::server_list.end();
		     b != e; ++b)
		{
			if ((*b)->certificate == id)
			{
				isused( (*b)->serverName);
				return true;
			}
		}

		if (id == myServer::smtpServerCertificate)
		{
			mail::loginInfo SMTPServerLoginInfo;

			mail::loginUrlDecode(myServer::smtpServerURL,
					     SMTPServerLoginInfo);

			isused(Gettext(_("%1% (SMTP server)")) <<
			       SMTPServerLoginInfo.server);
			return true;

		}

		myServer::promptInfo askdel(_("Delete this certificate? (Y/N) "));

		askdel=myServer::prompt(askdel.yesno());

		if (askdel.abortflag || (std::string)askdel != "Y")
			return true;

		parent->removeCertificate(myIter);
		return true;
	}

	if (key == key_RENAMECERTIFICATE)
	{
		myServer::promptInfo
			newname(_("New certificate name: "));

		newname=myServer::prompt(newname);

		if (newname.abortflag)
			return true;

		std::string newname_s=newname;

		if (newname_s.size() == 0)
			return true;

		myServer::certs->certs[id].name=newname_s;
		setText(newname_s);
		PasswordList::passwordList.save();
		return true;
	}

	return CursesButton::processKeyInFocus(key);
}
Пример #11
0
bool CursesMessageDisplay::processKeyInFocus(const Curses::Key &key)
{
	CursesMessage *messageInfo=messageInfoPtr;

	if (!messageInfo)
		return false;

	if (key == key.ENTER)
	{
		size_t row;
		size_t col;
		std::string url;

		if (!messageInfo->getCurrentLink(row, col, url))
			return true;


		if (url.substr(0, 7) == "mailto:")
		{
			if (myMessage::checkInterrupted(false) &&
			    (messageInfo=messageInfoPtr) != NULL)
				myMessage::newMessage(messageInfo->myfolder
						      ->getFolder(),
						      messageInfo->myfolder
						      ->getServer(),
						      url.substr(7));
			return true;
		}


		std::string handler;

		size_t p=url.find(':');

		if (p != std::string::npos)
		{
			handler=myServer::getConfigDir() + "/"
				+ url.substr(0, p) + ".handler";

			if (access(handler.c_str(), X_OK))
			{
				handler=FILTERDIR "/"
					+ url.substr(0, p) + ".handler";

				if (access(handler.c_str(), X_OK))
					handler="";
			}
		}

		if (handler.size() == 0)
		{
			statusBar->clearstatus();
			statusBar->
				status(Gettext(_("Cannot find handler for %1%"))
				       << url);
			statusBar->beepError();
			return true;
		}

		pid_t pp=fork();

		if (pp < 0)
		{
			statusBar->clearstatus();
			statusBar->status(strerror(errno));
			statusBar->beepError();
			return true;
		}

		if (pp == 0)
		{
			close(1);
			open("/dev/null", O_WRONLY);
			dup2(1, 2);
			dup2(1, 0);

			execl(handler.c_str(), handler.c_str(), url.c_str(),
			      (char *)NULL);

			exit(1);
		}

		pid_t p2;
		int waitstat;

		while ((p2=wait(&waitstat)) != pp)
		{
			if (p2 < 0 && errno != EINTR)
				break;
		}

		if (p2 == pp && WIFEXITED(waitstat) &&
		    WEXITSTATUS(waitstat) == 0)
		{
			statusBar->status(_("Started external handler."));
			return true;
		}

		statusBar->clearstatus();
		statusBar->status(_("External handler terminated with a non-zero exit code."),
				  statusBar->SYSERROR);
		return true;
	}

	if (key == key_TAKEADDR)
	{
		mail::envelope *e=messageInfo->getEnvelope();

		std::vector<mail::address> addrList;

		addrList.reserve(e->from.size() +
				 e->to.size() +
				 e->cc.size() +
				 e->bcc.size() +
				 e->sender.size() +
				 e->replyto.size());

		addrList.insert(addrList.end(),
				e->from.begin(),
				e->from.end());

		addrList.insert(addrList.end(),
				e->to.begin(),
				e->to.end());

		addrList.insert(addrList.end(),
				e->cc.begin(),
				e->cc.end());

		addrList.insert(addrList.end(),
				e->bcc.begin(),
				e->bcc.end());

		addrList.insert(addrList.end(),
				e->sender.begin(),
				e->sender.end());

		addrList.insert(addrList.end(),
				e->replyto.begin(),
				e->replyto.end());

		AddressBook::take(addrList);
		return true;
	}
	if (key == key_FOLDERINDEX ||
	    key == key_LESSTHAN)
	{
		keepgoing=false;
		myServer::nextScreen=&folderIndexScreen;
		myServer::nextScreenArg=messageInfo->myfolder;
		return true;
	}


	if (key == key_DELETE)
		messageInfo->myfolder->markDeleted( messageInfo->messagesortednum,
						    true, false);

	if (key == key_UNDELETE)
		messageInfo->myfolder->markDeleted( messageInfo->messagesortednum,
						    false, false);

	if (key == key_NEXTMESSAGE ||
	    key == key_DELETE ||
	    key == key_UNDELETE)
	{
		size_t dummy;

		if (messageInfo->myfolder->getNextMessage(dummy))
		{
			Curses::keepgoing=false;
			myServer::nextScreen= &goNextMessage;
			myServer::nextScreenArg=messageInfo->myfolder;
			return true;
		}
		return true;
	}

	if (key == key_PREVMESSAGE)
	{
		size_t dummy;

		if (messageInfo->myfolder->getPrevMessage(dummy))
		{
			Curses::keepgoing=false;
			myServer::nextScreen= &goPrevMessage;
			myServer::nextScreenArg=messageInfo->myfolder;
		}
		return true;
	}

	if (key == ' ' || key == Key::RIGHT ||
	    key == Key::PGDN || key == Key::DOWN)
	{
		if ((key == Key::DOWN || key == Key::RIGHT) &&
		    messageInfo->nextLink())
			return true; // Went to next link instead

		size_t nLines=messageInfo->nLines();
		size_t h=getHeight();

		size_t lastLine= nLines > h ? nLines-h:0;

		size_t firstLineSaved=getFirstLineShown();

		if (key == Key::DOWN || key == Key::RIGHT)
			setFirstLineShown(getFirstLineShown()+1);
		else
			setFirstLineShown(getFirstLineShown()+h);

		if (getFirstLineShown() > lastLine)
			setFirstLineShown(lastLine);

		if (firstLineSaved == getFirstLineShown() && key == ' ')
		{
			size_t dummy;

			if (messageInfo->myfolder->
			    getNextUnreadMessage(dummy))
			{
				Curses::keepgoing=false;
				myServer::nextScreen= &goNextUnreadMessage;
				myServer::nextScreenArg=messageInfo->myfolder;
				return true;
			}

			statusBar->clearstatus();
			statusBar->status(Gettext(_("No more unread mail in %1%"))
					  << messageInfo->myfolder
					  ->getFolder()->getName());
			return true;
		}

		folderUpdated();
		draw2();
		messageInfo->toLastLink();
		return true;
	}

	if (key == Key::LEFT || key == Key::PGUP || key == Key::UP)
	{
		if (key != Key::PGUP && messageInfo->prevLink())
			return true;

		size_t h=key != Key::PGUP ? 1:getHeight();

		setFirstLineShown(getFirstLineShown() < h ? 0:
				  getFirstLineShown()-h);
		folderUpdated();
		draw2();
		return true;
	}

	if (key == key_VIEWATT)
	{
		Curses::keepgoing=false;
		myServer::nextScreen=showAttachments;
		myServer::nextScreenArg=messageInfo;
		return true;
	}

	if (key == key_SAVE)
	{
		std::string filename;

		{
			SaveDialog save_dialog(filename);

			save_dialog.requestFocus();
			myServer::eventloop();

			filename=save_dialog;
			mainScreen->erase();
		}
		mainScreen->draw();
		requestFocus();

		if (messageInfoPtr.isDestroyed() || filename == "")
			return true;

		CursesAttachmentDisplay::downloadTo(messageInfoPtr,
						    messageInfoPtr->shownMimeId
						    != ""
						    ?
						    messageInfoPtr->structure
						    .find(messageInfoPtr->
							  shownMimeId)
						    :NULL,
						    filename);
		return true;
	}


	if (key == key_BOUNCE)
	{
		if (messageInfo->shownMimeId.size())
		{
			statusBar->clearstatus();
			statusBar->status(_("Cannot forward only an attachment, just the whole message."));
			statusBar->beepError();
			return true;
		}

		mail::smtpInfo sendInfo;

		std::string from;
		std::string replyto;
		std::string fcc;
		std::string customheaders;

		if (!myMessage::getDefaultHeaders(messageInfo->myfolder
						  ->getFolder(),
						  messageInfo->myfolder
						  ->getServer(),
						  from, replyto, fcc,
						  customheaders))
		{
			return true;
		}

		{
			std::vector<mail::address> addrList;
			size_t errIndex;

			if (mail::address::fromString(from, addrList,
						      errIndex)
			    && addrList.size() > 0)
				sendInfo.sender=addrList[0].getAddr();
		}

		mail::ptr<myFolder> folderPtr=messageInfo->myfolder;

		if (!CursesMessage::getBounceTo(sendInfo)
		    || !CursesMessage::getSendInfo(Gettext(_("Blind-forward message to %1% address(es)? (Y/N) "))
						   << sendInfo.recipients
						   .size(), "",
						   sendInfo, NULL))
			return true;

		disconnectCallbackStub disconnectStub;
		myServer::Callback sendCallback;

		mail::account *smtpServer;
		mail::folder *folder=
			CursesMessage::getSendFolder(sendInfo, smtpServer,
						     NULL,
						     disconnectStub);

		if (!folder)
			return true;

		if (folderPtr.isDestroyed() || messageInfoPtr.isDestroyed())
		{
			delete folder;
			if (smtpServer)
				delete smtpServer;
			return true;
		}

		try {
			messageInfo->copyContentsTo(folder, sendCallback);

			bool rc=myServer::eventloop(sendCallback);

			delete folder;
			folder=NULL;

			if (smtpServer)
			{
				if (rc)
				{
					myServer::Callback disconnectCallback;

					disconnectCallback.noreport=true;

					smtpServer->logout(disconnectCallback);
					myServer::
						eventloop(disconnectCallback);
				}

				delete smtpServer;
				smtpServer=NULL;
			}
			

		} catch (...) {

			if (folder)
				delete folder;
			if (smtpServer)
				delete smtpServer;
			LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
		}

		return true;
	}

	if (key == key_REPLY)
	{
		mail::ptr<myFolder> folder=messageInfo->myfolder;

		if (myMessage::checkInterrupted() &&
		    !folder.isDestroyed() &&
		    !messageInfoPtr.isDestroyed())
			messageInfo->reply();
		return true;
	}

	if (key == key_FWD)
	{
		mail::ptr<myFolder> folder=messageInfo->myfolder;

		if (myMessage::checkInterrupted() &&
		    !folder.isDestroyed() &&
		    !messageInfoPtr.isDestroyed())
			messageInfo->forward();
		return true;
	}

	if (key == key_HEADERS)
	{
		erase();
		messageInfo->fullEnvelopeHeaders=
			!messageInfo->fullEnvelopeHeaders;
		setFirstLineShown(0);
		messageInfo->beginReformat(getWidth());
		folderUpdated();
		return true;
	}

	if (key == key_PRINT)
	{
		mail::ptr<CursesMessage> ptr=messageInfo;
		int pipefd[2];
		pid_t pid1;

		myServer::promptInfo
			printPrompt(_("Print to: "));

		if (printCommand.size() == 0)
			printCommand="lpr";

		printPrompt=myServer::prompt(printPrompt
					     .initialValue(printCommand));

		if (printPrompt.abortflag || ptr.isDestroyed())
			return true;

		std::vector<const char *> args;

		{
			const char *p=getenv("SHELL");

			if (!p || !*p)
				p="/bin/sh";

			args.push_back(p);
		}

		args.push_back("-c");

		printCommand=printPrompt;

		args.push_back(printCommand.c_str());
		args.push_back(0);

		//
		// Fork a child process which writes the text image of the
		// message to a pipe.
		//
		// The parent process runs the print command, piping the text
		// into it.

		signal(SIGCHLD, SIG_DFL);

		if (pipe(pipefd) < 0)
		{
			statusBar->clearstatus();
			statusBar->status(strerror(errno));
			statusBar->beepError();
			return true;
		}

		if ((pid1=fork()) == 0)
		{
			FILE *fp;

			// First child exits, the second child generates the
			// text.

			if (fork())
				exit(0);
			signal(SIGPIPE, SIG_DFL);
			close(pipefd[0]);

			fp=fdopen(pipefd[1], "w");
			if (fp)
			{
				size_t nLines=messageInfo->nLines();
				size_t i;
				std::vector<std::pair<textAttributes, std::string> > line;

				std::vector<std::pair<textAttributes, std::string> >
					::iterator b, e;

				for (i=0; i<nLines; i++)
				{
					messageInfo->getLineImage(i, line);

					for (b=line.begin(), e=line.end();
					     b != e; ++b)
					{
						fprintf(fp, "%s",
							b->second.c_str());
					}
					fprintf(fp, "\n");
				}
				fflush(fp);
			}
			exit(0);
		}

		// Wait for the first child to exit.

		if (pid1 < 0)
		{
			close(pipefd[0]);
			close(pipefd[1]);
			statusBar->clearstatus();
			statusBar->status(strerror(errno));
			statusBar->beepError();
			return true;
		}

		close(pipefd[1]);

		while (wait(NULL) != pid1)
			;

		Curses::runCommand(args, pipefd[0], "");
		close(pipefd[0]);
		return true;
	}

	if (key == key_ROT13)
	{
		erase();
		messageInfo->rot13=!messageInfo->rot13;
		setFirstLineShown(0);
		messageInfo->beginReformat(getWidth());
		folderUpdated();
		return true;
	}

	if ((key == key_UNENCRYPT) &&
	    (messageInfo->isSigned() ||
	     messageInfo->isEncrypted()) &&
	    GPG::gpg.gpg_installed())
	{
		mail::ptr<CursesMessage> ptr=messageInfo;
		std::string passphrase;
		std::vector<std::string> options;
		bool wasEncrypted=messageInfo->isEncrypted();

		if (wasEncrypted)
		{
			if (!PasswordList::passwordList.check("decrypt:",
							      passphrase))
			{

				myServer::promptInfo
					passPrompt(_("Passphrase (if"
						     " required): "));

				passPrompt=myServer::prompt(passPrompt
							    .password());

				if (passPrompt.abortflag || ptr.isDestroyed())
					return true;

				passphrase=passPrompt;
			}
		}

		std::string::iterator b=GPG::gpg.extraDecryptVerifyOptions.begin();

		while (b != GPG::gpg.extraDecryptVerifyOptions.end())
		{
			if (unicode_isspace((unsigned char)*b))
			{
				b++;
				continue;
			}

			std::string::iterator s=b;

			while (b != GPG::gpg.extraDecryptVerifyOptions.end())
			{
				if (unicode_isspace((unsigned char)*b))
					break;
				b++;
			}

			options.push_back(std::string(s, b));
		}

		bool decryptFailed;

		if (messageInfo->decrypt(passphrase, options, decryptFailed))
		{
			if (wasEncrypted && !decryptFailed)
				PasswordList::passwordList
					.save("decrypt:", passphrase);

			erase();
			setFirstLineShown(0);
			messageInfo->beginReformat(getWidth());
			folderUpdated();

			if (wasEncrypted && decryptFailed)
			{
				statusBar->clearstatus();
				statusBar->status(_("ERROR: Decryption failed,"
						    " passphrase forgotten."));
				statusBar->beepError();
			}
		}

		return true;
	}
	
	if (key == key_MSGSEARCH)
	{
		mail::ptr<CursesMessage> ptr=messageInfo;

		myServer::promptInfo searchPrompt(_("Search: "));

		searchPrompt=myServer::prompt(searchPrompt
					      .initialValue(searchString));

		if (searchPrompt.abortflag || ptr.isDestroyed())
			return true;

		searchString=searchPrompt;

		if (searchString.size() == 0)
			return true;

		mail::Search searchEngine;

		if (!searchEngine.setString(searchString,
					    unicode_default_chset()))
		{
			statusBar->clearstatus();
			statusBar->status(strerror(errno));
			statusBar->beepError();
			return true;
		}

		searchEngine.reset();

		statusBar->clearstatus();
		statusBar->status(_("Searching..."));
		statusBar->flush();

		size_t n=messageInfo->nLines();

		std::vector<std::pair<textAttributes, std::string> > line;

		while (firstLineToSearch < n)
		{
			messageInfo->getLineImage(firstLineToSearch, line);

			std::string s;

			std::vector<std::pair<textAttributes, std::string> >
				::iterator b, e;

			for (b=line.begin(), e=line.end(); b != e; ++b)
				s += Gettext::toutf8(b->second);

			unicode_char *uc;
			size_t ucsize;

			if (unicode_convert_tou_tobuf(s.c_str(),
							s.size(),
							"utf-8",
							&uc,
							&ucsize,
							NULL))
			{
				statusBar->clearstatus();
				statusBar->status(strerror(errno));
				statusBar->beepError();
				return true;
			}

			if (ucsize == 0)
			{
				free(uc);
				++firstLineToSearch;
				continue;
			}

			size_t i;

			for (i=0; i<ucsize; ++i)
			{
				searchEngine << uc[i];
			}
			free(uc);
			searchEngine << (unicode_char)' '; // EOL

			if (searchEngine)
			{
				size_t nLines=messageInfo->nLines();
				size_t h=getHeight();
				size_t lastLine= nLines > h ? nLines-h:0;

				size_t foundAt=firstLineToSearch;

				size_t n=foundAt > 0 ? foundAt-1:0;

				if (n > lastLine)
					n=lastLine;

				setFirstLineShown(n);
				firstLineToSearch=foundAt+1;

				statusBar->clearstatus();
				statusBar->status(Gettext(_("Text located,"
							    " displayed on"
							    " line #%1%"))
						  << (firstLineToSearch-n));
				draw();
				return true;
			}
			++firstLineToSearch;
		}
		statusBar->clearstatus();
		statusBar->status(_("Not found."));
		return true;
	}

	if (key.fkey())
	{
		std::string local_cmd;

		if (!CursesIndexDisplay::FilterMessageCallback
		    ::getFilterCmd(key.fkeynum(), local_cmd))
			return true;

		CursesIndexDisplay::FilterMessageCallback cb(local_cmd);

		std::vector<size_t> msgvec;

		msgvec.push_back(messageInfo->myfolder->getServerIndex
				 (messageInfo->myfolder->getCurrentMessage()));

		messageInfo->myfolder->getServer()
			->server->readMessageContent(msgvec, true,
						     mail::readBoth, cb);

		if (myServer::eventloop(cb))
		{
			cb.finish();

			if (myServer::nextScreen)
				return true;

			if (cb.errmsg.size())
			{
				statusBar->clearstatus();
				statusBar->status(cb.errmsg);
				statusBar->beepError();
			}
		}
		return true;
	}
	return false;
}
Пример #12
0
BOOL XXX(LPVOID pItem,char *pSubString)
{
	
	
	T_X86Instruction      tX86Instruction;
	
	t_dump                *pX86Dasm=NULL;
    ulong                  Address;
	ulong                  SOffest,EOffset;
	ulong                  i;
	unsigned char         InstStr[MAXCMDSIZE];
	ulong                 InstLength;
    t_disasm              da;
    unsigned char         *pdecode=NULL; 

	t_dump *pDasmWnd=(t_dump*)Plugingetvalue(VAL_CPUDASM);
	
	
	pX86Dasm=(	t_dump *)pItem;
	Address=pX86Dasm->base;
	

	char                 cPattern[0x100]={0};
	if (Gettext("Search for pattern ...",cPattern,0,0,Plugingetvalue(VAL_WINDOWFONT))==-1){


		return FALSE;
	}
	
	
	
	
	while(Address=Findnextproc(Address)){
		
	  Getproclimits(Address,&SOffest,&EOffset);
		
		
		
		for (i=SOffest; i<EOffset; ){
			
			if (!Readcommand(i,(char*)InstStr)) break;
			
			
		
			InstLength=Disasm(InstStr,MAXCMDSIZE,i,pdecode,&da,DISASM_CODE,0); 
			
			
			
			tX86Instruction.Addresss=i;
			memcpy(tX86Instruction.Command,da.result,256);
			tX86Instruction.OpCodeLength=InstLength;
			
			if (strstr((char*)tX86Instruction.Command,cPattern) ) {
				
				if (pSubString){ 
					if (strstr((char*)tX86Instruction.Command,pSubString)){
						
						
						DbgMsg("0x%08X %d %s ",
							tX86Instruction.Addresss,
							tX86Instruction.OpCodeLength,
							tX86Instruction.Command);
						
							
						
						Setbreakpoint(tX86Instruction.Addresss,TY_ACTIVE|TY_KEEPCODE,0);
					}
						i+=InstLength;
						continue;
				}
					DbgMsg("0x%08X %d %s ",
							tX86Instruction.Addresss,
							tX86Instruction.OpCodeLength,
							tX86Instruction.Command);
							Setbreakpoint(tX86Instruction.Addresss,TY_ACTIVE|TY_KEEPCODE,0);
				

			}
				
				
			i+=InstLength;
			
		}
		
		
		
		
		
		
	}
	
	
	
	
	return TRUE;
	



}