Exemplo n.º 1
0
QString Log::getLogString(){
    return QString(QObject::tr("%1 [%2] `%4` <%5> : %3")).arg(time.toString("yyyy/MM/dd hh:mm:ss"))
            .arg(getTypeName())
            .arg(getText())
            .arg(getNote())
            .arg(getReturnValue());
}
Exemplo n.º 2
0
int Logic::requestSimpleResult(const PolicyKey &key, PolicyResult &result) {
    auto simpleCheckResponse = requestResponse<SimpleCheckRequest, SimpleCheckResponse>(key);
    if (!simpleCheckResponse) {
        LOGC("Critical error. Requesting SimpleCheckResponse failed.");
        return CYNARA_API_SERVICE_NOT_AVAILABLE;
    }

    if (simpleCheckResponse->getReturnValue() != CYNARA_API_SUCCESS)
        return simpleCheckResponse->getReturnValue();

    LOGD("SimpleCheckResponse: policyType = %" PRIu16 ", metadata = %s",
         simpleCheckResponse->getResult().policyType(),
         simpleCheckResponse->getResult().metadata().c_str());

    result = simpleCheckResponse->getResult();
    return CYNARA_API_SUCCESS;
}
Exemplo n.º 3
0
string Dialog::execInputBox(string header, string default_text, unsigned int height, unsigned int width)
{
	string tmp_file = get_tmp_file();
	string exec_str = dialog + " --inputbox \"" + header + "\" " + IntToStr(height) + " " + IntToStr(width) + " \"" + default_text + "\"" + " 2>"+tmp_file;
	system(exec_str.c_str());
	string ret = getReturnValue(tmp_file);
	unlink(tmp_file.c_str());
	return ret;
}
void InvokeMethodResponseHandler::transfer()
{
    CIMInvokeMethodResponseMessage& msg =
        *static_cast<CIMInvokeMethodResponseMessage*>(getResponse());

    msg.outParameters = getParamValues();

    // ATTN-RK-20020903: Is it legal for the return value to be null?
    // if not, then the check must be done here since deliver() works off the
    // virtual size, which refers to out parameters!
    msg.retValue = getReturnValue();
}
Exemplo n.º 5
0
string Dialog::execMenu(string header, unsigned int height, unsigned int width, unsigned int menu_height, vector<TagPair> menuItems, string default_item)
{
	if (menuItems.empty())
	{
		mError("Empty item list");
		return "";
	}
	string tmp_file = get_tmp_file();
	string def_item;
	if (!default_item.empty()) 
	{
		for (unsigned int i=0; i<menuItems.size(); i++)
		{
			if (menuItems[i].tag==default_item)
			{
				def_item = "--default-item \"" + default_item + "\"";
				printf("set to %s\n", def_item.c_str());
			}
		}
		if (def_item.empty())
		{
			mError("No such item " + default_item + ", using defaults");
			sleep(1);
		}
	}
	string exec_str = dialog + " " + def_item + " --menu \"" + header + "\" " + IntToStr(height) + " " + IntToStr(width) + " " + IntToStr(menu_height);
	for (unsigned int i=0; i<menuItems.size(); i++)
	{
		exec_str += " \"" + menuItems[i].tag + "\" \"" + menuItems[i].value+"\"";
	}
	exec_str += " 2>"+tmp_file;
	system(exec_str.c_str());
	string ret = getReturnValue(tmp_file);
	unlink(tmp_file.c_str());
	return ret;
}
Exemplo n.º 6
0
void Dialog::execAddableList(string header, vector<string> *menuItems, string tagLimiter)
{
	// Legend:
	// tagLimiter, for exapmle, may be equal to "://" - this means that the value of "ftp://something.com" will be splitted in next way:
	// 	ftp will be a value (or assotiated comment using internal database), and something.com will be a tag.
	string tmp_file, exec_str, value;
	vector<TagPair> menuList;
	vector<string> tmpList;
	int ret;
	unsigned int pos;
	tmp_file = get_tmp_file();

begin:
	exec_str = dialog + " --ok-label \"Удалить\" --cancel-label \"Продолжить\" --extra-button --extra-label \"Добавить\" --menu \"" + header + "\" " + \
			   IntToStr(0) + " " + IntToStr(0) + " " + IntToStr(0);

	menuList.clear();
	if (!tagLimiter.empty())
	{
		for (unsigned int i=0; i<menuItems->size(); i++)
		{
			pos = menuItems->at(i).find(tagLimiter);
			if (pos!=std::string::npos)
			{
				menuList.push_back(TagPair(menuItems->at(i), resolveComment(menuItems->at(i).substr(0, pos))));
			}
			else
			{
				menuList.push_back(TagPair(menuItems->at(i), "Некорректный URL"));
			}
		}
	}
	for (unsigned int i=0; i<menuList.size(); i++)
	{
		exec_str += " \"" + menuList[i].tag + "\" \"" + menuList[i].value + "\" ";
	}
	exec_str += " 2>"+tmp_file;
	ret = system(exec_str.c_str());
	printf("returned %i\n", ret);
	switch(ret)
	{
		case 256: // OK button
			printf("Ok\n");
			return;
			break;
		case 768: // Add button
			value = execInputBox("Введите URL репозитория:", "");
			if (!value.empty())
			{
				menuItems->push_back(value);
			}
			goto begin;
			break;
		case 0:	// Delete button
			mError("delete button");
			value = getReturnValue(tmp_file);
			if (!value.empty())
			{
				if (menuList.size()==1)
				{
					execMsgBox("Список не может быть пустым. Сначала добавьте еще что-нибудь");
					goto begin;
				}
				for (unsigned int i=0; i<menuList.size(); i++)
				{
					if (menuList[i].tag == value)
					{
						tmpList.clear();
						for (unsigned int t=0; t<menuItems->size(); t++)
						{
							if (menuItems->at(t)!=value)
							{
								tmpList.push_back(menuItems->at(t));
							}
						}
						*menuItems = tmpList;
						tmpList.clear();
						mDebug("Deleted " + value);
						goto begin;
					}
				}
				mError("out of cycle");
				goto begin;
			}
			else
			{
				mDebug("empty value");
			}
			goto begin;
			break;
		default: // Cancel, ESC, and other errors
			mError(exec_str);
			mDebug("Returned " +  IntToStr(ret));
			sleep(2);
			
			return;		
/*			if (execYesNo("Действительно прервать?")) abort();
			else goto begin;*/
	}
}