Exemplo n.º 1
0
QString AWebservice::getUserList_WebserviceParse (const QString& data, AUserInfoList& list, QString& row_version, IProgress* progress)
{
	if (progress != NULL)
		progress->onProgress(0);

	list.clear();

	row_version = "";

	int seed = 0;

	QString user_info = getNextBlock(&data, "<JanusUserInfo>", "</JanusUserInfo>", seed);

	while (user_info.length())
	{
		AUserInfo info;

		info.ID             = getTextBetween(&user_info, "<userId>",         "</userId>").toInt();
		info.Name           = getTextBetween(&user_info, "<userName>",       "</userName>");
		info.Nick           = getTextBetween(&user_info, "<userNick>",       "</userNick>");
		info.RealName       = getTextBetween(&user_info, "<realName>",       "</realName>");
		info.Email          = getTextBetween(&user_info, "<publicEmail>",    "</publicEmail>");
		info.Homepage       = getTextBetween(&user_info, "<homePage>",       "</homePage>");
		info.Specialization = getTextBetween(&user_info, "<specialization>", "</specialization>");
		info.WhereFrom      = getTextBetween(&user_info, "<whereFrom>",      "</whereFrom>");
		info.Origin         = getTextBetween(&user_info, "<origin>",         "</origin>");

		list.append(info);

		user_info = getNextBlock(&data, "<JanusUserInfo>", "</JanusUserInfo>", seed);
	}

	seed = 0;
	row_version = getNextBlock(&data, "<lastRowVersion>", "</lastRowVersion>", seed);

	// проверка ошибок получения версий строк
	// подавлять ошибки сбросом в значение по умолчанию ("AAAAAAAAAAA=") оказалось неправильно
	// подробнее см. http://www.rsdn.ru/forum/janus/3449147.1.aspx
	if (row_version.length() == 0)
		return QString::fromUtf8("В ответе вебсервиса не найдено поле <lastRowVersion>");

	return "";
}
Exemplo n.º 2
0
String CodeDocument::getAllContent() const
{
    return getTextBetween (Position (this, 0),
                           Position (this, lines.size(), 0));
}
Exemplo n.º 3
0
QString AWebservice::parsePostChangeCommit (const QString& data, ACommitInfo& commit_info)
{
	int seed = 0;

	QString messages = getTextBetween(&data, "<commitedIds>", "</commitedIds>");

	QString id_info = getNextBlock(&messages, "<int>", "</int>", seed);

	while (id_info.length())
	{
		commit_info.Messages.append(id_info.toInt());

		id_info = getNextBlock(&messages, "<int>", "</int>", seed);
	}

	seed = 0;

	QString message_exceptions = getTextBetween(&data, "<exceptions>", "</exceptions>");

	QString message_exception_info = getNextBlock(&message_exceptions, "<PostExceptionInfo>", "</PostExceptionInfo>", seed);

	while (message_exception_info.length())
	{
		ACommitExceptionInfo info;

		info.Exception = getTextBetween(&message_exception_info, "<exception>",      "</exception>");
		info.ID        = getTextBetween(&message_exception_info, "<localMessageId>", "</localMessageId>").toInt();
		info.Info      = getTextBetween(&message_exception_info, "<info>",           "</info>");

		commit_info.MessagesExceptions.append(info);

		message_exception_info = getNextBlock(&message_exceptions, "<PostExceptionInfo>", "</PostExceptionInfo>", seed);
	}

	seed = 0;

	QString ratings = getTextBetween(&data, "<commitedRatingIds>", "</commitedRatingIds>");

	id_info = getNextBlock(&ratings, "<int>", "</int>", seed);

	while (id_info.length())
	{
		commit_info.Rating.append(id_info.toInt());

		id_info = getNextBlock(&ratings, "<int>", "</int>", seed);
	}

	seed = 0;

	QString rating_exceptions = getTextBetween(&data, "<ratingExceptions>", "</ratingExceptions>");

	QString rating_exception_info = getNextBlock(&rating_exceptions, "<RatingExceptionInfo>", "</RatingExceptionInfo>", seed);

	while (rating_exception_info.length())
	{
		ACommitExceptionInfo info;

		info.Exception = getTextBetween(&rating_exception_info, "<exception>",     "</exception>");
		info.ID        = getTextBetween(&rating_exception_info, "<localRatingId>", "</localRatingId>").toInt();
		info.Info      = getTextBetween(&rating_exception_info, "<info>",          "</info>");

		commit_info.RatingExceptions.append(info);

		rating_exception_info = getNextBlock(&rating_exceptions, "<RatingExceptionInfo>", "</RatingExceptionInfo>", seed);
	}

	seed = 0;

	QString moderates = getTextBetween(&data, "<commitedModerateIds>", "</commitedModerateIds>");

	id_info = getNextBlock(&moderates, "<int>", "</int>", seed);

	while (id_info.length())
	{
		commit_info.Moderate.append(id_info.toInt());

		id_info = getNextBlock(&moderates, "<int>", "</int>", seed);
	}

	seed = 0;

	QString moderate_exceptions = getTextBetween(&data, "<moderateExceptions>", "</moderateExceptions>");

	QString moderate_exception_info = getNextBlock(&moderate_exceptions, "<ModerateExceptionInfo>", "</ModerateExceptionInfo>", seed);

	while (moderate_exception_info.length())
	{
		ACommitExceptionInfo info;

		info.Exception = getTextBetween(&moderate_exception_info, "<ExceptionMessage>", "</ExceptionMessage>");
		info.ID        = getTextBetween(&moderate_exception_info, "<LocalModerateId>",  "</LocalModerateId>").toInt();
		info.Info      = getTextBetween(&moderate_exception_info, "<Info>",             "</Info>");

		commit_info.MessagesExceptions.append(info);

		moderate_exception_info = getNextBlock(&moderate_exceptions, "<ModerateExceptionInfo>", "</ModerateExceptionInfo>", seed);
	}

	return "";
}
Exemplo n.º 4
0
QString AWebservice::parseMessageList (const QString& data, ADataList& list, ARowVersion& row_version)
{
	list.Rating.clear();
	list.Message.clear();
	list.Moderate.clear();

	int seed = 0;

	QString message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed);

	while (message_info.length())
	{
		AMessageInfo info;

		info.ID             = getTextBetween(&message_info, "<messageId>",      "</messageId>").toInt();
		info.IDTopic        = getTextBetween(&message_info, "<topicId>",        "</topicId>").toInt();
		info.IDParent       = getTextBetween(&message_info, "<parentId>",       "</parentId>").toInt();
		info.IDUser         = getTextBetween(&message_info, "<userId>",         "</userId>").toInt();
		info.IDForum        = getTextBetween(&message_info, "<forumId>",        "</forumId>").toInt();
		info.Subject        = getTextBetween(&message_info, "<subject>",        "</subject>");
		info.MessageName    = getTextBetween(&message_info, "<messageName>",    "</messageName>");
		info.UserNick       = getTextBetween(&message_info, "<userNick>",       "</userNick>");
		info.Message        = getTextBetween(&message_info, "<message>",        "</message>");
		info.IDArticle      = getTextBetween(&message_info, "<articleId>",      "</articleId>").toInt();
		info.MessageDate    = getDateTimeFromString(getTextBetween(&message_info, "<messageDate>", "</messageDate>"));
		info.UpdateDate     = getDateTimeFromString(getTextBetween(&message_info, "<updateDate>", "</updateDate>"));
		info.UserRole       = getTextBetween(&message_info, "<userRole>",       "</userRole>");
		info.UserTitle      = getTextBetween(&message_info, "<userTitle>",      "</userTitle>");
		info.UserTitleColor = getTextBetween(&message_info, "<userTitleColor>", "</userTitleColor>").toInt();
		info.LastModerated  = getDateTimeFromString(getTextBetween(&message_info, "<lastModerated>", "</lastModerated>"));
		info.Closed         = getBooleanFromString(getTextBetween(&message_info, "<closed>", "</closed>"));

		if (info.MessageDate.isValid() == false)
			return QString::fromUtf8("Некорректное значение даты <messageDate>: ") + getTextBetween(&message_info, "<messageDate>", "</messageDate>");

		if (info.UpdateDate.isValid() == false)
			return QString::fromUtf8("Некорректное значение даты <updateDate>: ") + getTextBetween(&message_info, "<updateDate>", "</updateDate>");

		if (info.LastModerated.isValid() == false)
			return QString::fromUtf8("Некорректное значение даты <lastModerated>: ") + getTextBetween(&message_info, "<lastModerated>", "</lastModerated>");

		list.Message.append(info);

		message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed);
	}

	seed = 0;

	QString rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed);

	while (rating_info.length())
	{
		ARatingInfo info;

		info.IDMessage  = getTextBetween(&rating_info, "<messageId>",  "</messageId>").toInt();
		info.IDTopic    = getTextBetween(&rating_info, "<topicId>",    "</topicId>").toInt();
		info.IDUser     = getTextBetween(&rating_info, "<userId>",     "</userId>").toInt();
		info.UserRating = getTextBetween(&rating_info, "<userRating>", "</userRating>").toInt();
		info.Rate       = getTextBetween(&rating_info, "<rate>",       "</rate>").toInt();
		info.RateDate   = getDateTimeFromString(getTextBetween(&rating_info, "<rateDate>", "</rateDate>"));

		if (info.RateDate.isValid() == false)
			return QString::fromUtf8("Некорректное значение даты <rateDate>: ") + getTextBetween(&rating_info, "<rateDate>", "</rateDate>");

		list.Rating.append(info);

		rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed);
	}

	seed = 0;

	QString moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed);

	while (moderate_info.length())
	{
		AModerateInfo info;

		info.IDMessage = getTextBetween(&moderate_info, "<messageId>", "</messageId>").toInt();
		info.IDTopic   = getTextBetween(&moderate_info, "<topicId>",   "</topicId>").toInt();
		info.IDUser    = getTextBetween(&moderate_info, "<userId>",    "</userId>").toInt();
		info.IDForum   = getTextBetween(&moderate_info, "<forumId>",   "</forumId>").toInt();
		info.Created   = getDateTimeFromString(getTextBetween(&moderate_info, "<create>", "</create>"));

		if (info.Created.isValid() == false)
			return QString::fromUtf8("Некорректное значение даты <create>: ") + getTextBetween(&moderate_info, "<create>", "</create>");

		list.Moderate.append(info);

		moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed);
	}

	seed = 0;
        QString lastRatingRowVersion   = getNextBlock(&data, "<lastRatingRowVersion>",   "</lastRatingRowVersion>",   seed);
	seed = 0;
        QString lastForumRowVersion    = getNextBlock(&data, "<lastForumRowVersion>",    "</lastForumRowVersion>",    seed);
	seed = 0;
        QString lastModerateRowVersion = getNextBlock(&data, "<lastModerateRowVersion>", "</lastModerateRowVersion>", seed);

	// проверка ошибок получения версий строк
	// подавлять ошибки сбросом в значение по умолчанию ("AAAAAAAAAAA=") оказалось неправильно
	// подробнее см. https://rsdn.ru/forum/janus/3449147.1
	// выбрасывать ошибку (r253) тоже оказалось неправильно - для некоторых форумов не приходят ни рейтинги ни модерилки
	if (lastRatingRowVersion.length() != 0)
		row_version.Rating = lastRatingRowVersion;
	if (lastForumRowVersion.length() != 0)
		row_version.Message = lastForumRowVersion;
	if (lastModerateRowVersion.length() != 0)
		row_version.Moderate = lastModerateRowVersion;

	return "";
}
Exemplo n.º 5
0
void AWebservice::parseForumList (const QString& data, AForumGroupInfoList& list)
{
	list.clear();

	//
	// список групп форумов
	//

	AGroupInfoList group_list;

	int seed = 0;

	QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);

	while (group_info.length())
	{
		AGroupInfo info;

		info.ID        = getTextBetween(&group_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.Name      = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>");
		info.SortOrder = getTextBetween(&group_info, "<sortOrder>",      "</sortOrder>").toInt();

		group_list.append(info);

		group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);
	}

	//
	// список форумов
	//

	AForumInfoList forum_list;

	seed = 0;

	QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);

	while (forum_info.length())
	{
		AForumInfo info;

		info.ID        = getTextBetween(&forum_info, "<forumId>",        "</forumId>").toInt();
		info.IDGroup   = getTextBetween(&forum_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>");
		info.Name      = getTextBetween(&forum_info, "<forumName>",      "</forumName>");
		info.Rated     = getTextBetween(&forum_info, "<rated>",          "</rated>").toInt();
		info.InTop     = getTextBetween(&forum_info, "<inTop>",          "</inTop>").toInt();
		info.RateLimit = getTextBetween(&forum_info, "<rateLimit>",      "</rateLimit>").toInt();

		forum_list.append(info);

		forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);
	}

	//
	// заполнение результата
	//

	for (int group_index = 0; group_index < group_list.count(); group_index++)
	{
		AForumGroupInfo group_info;

		group_info.Group = group_list[group_index];

		for (int forum_index = 0; forum_index < forum_list.count(); forum_index++)
			if (forum_list[forum_index].IDGroup == group_info.Group.ID)
				group_info.Forums.append(forum_list[forum_index]);

		list.append(group_info);
	}
}
Exemplo n.º 6
0
void AWebservice::getForumList_WebserviceParse (const QString& data, AForumGroupInfoList& list, IProgress* progress)
{
	if (progress != NULL)
		progress->onProgress(0);

	list.clear();

	//
	// список групп форумов
	//

	AGroupInfoList group_list;

	int seed = 0;

	QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);

	while (group_info.length())
	{
		AGroupInfo info;

		info.ID        = getTextBetween(&group_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.Name      = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>");
		info.SortOrder = getTextBetween(&group_info, "<sortOrder>",      "</sortOrder>").toInt();

		group_list.append(info);

		group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);
	}

	//
	// список форумов
	//

	AForumInfoList forum_list;

	seed = 0;

	QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);

	while (forum_info.length())
	{
		AForumInfo info;

		info.ID        = getTextBetween(&forum_info, "<forumId>",        "</forumId>").toInt();
		info.IDGroup   = getTextBetween(&forum_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>");
		info.Name      = getTextBetween(&forum_info, "<forumName>",      "</forumName>");
		info.Rated     = getTextBetween(&forum_info, "<rated>",          "</rated>").toInt();
		info.InTop     = getTextBetween(&forum_info, "<inTop>",          "</inTop>").toInt();
		info.RateLimit = getTextBetween(&forum_info, "<rateLimit>",      "</rateLimit>").toInt();

		forum_list.append(info);

		forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);
	}

	//
	// заполнение результата
	//

	for (int group_index = 0; group_index < group_list.count(); group_index++)
	{
		AForumGroupInfo group_info;

		group_info.Group = group_list[group_index];

		for (int forum_index = 0; forum_index < forum_list.count(); forum_index++)
			if (forum_list[forum_index].IDGroup == group_info.Group.ID)
				group_info.Forums.append(forum_list[forum_index]);

		list.append(group_info);
	}

	//
	// добавление "мусорки"
	//

	/*
	AForumGroupInfo trash_group;

	trash_group.Group.ID        = 0;
	trash_group.Group.Name      = QString::fromUtf8("Корзина");
	trash_group.Group.SortOrder = 10000;

	AForumInfo trash_forum;

	trash_forum.ID        = 0;
	trash_forum.IDGroup   = 0;
	trash_forum.ShortName = "trash";
	trash_forum.Name      = QString::fromUtf8("Удаленные");
	trash_forum.Rated     = true;
	trash_forum.InTop     = true;
	trash_forum.RateLimit = 0;

	trash_group.Forums.append(trash_forum);

	list.append(trash_group);
	*/
}