<commit_before>/*
 * Copyright (c) MZ3 Project Team All rights reserved.
 * Code licensed under the BSD License:
 * http://www.mz3.jp/license.txt
 */
#include "stdafx.h"
#include "MZ3.h"
#include "Mz3GroupData.h"
#include "util_base.h"
#include "util_mz3.h"
#include "inifile.h"

/**
 * gbvy[Wp̏
 *
 * O[vXgƂ̔z̃Xg̐B
 */
bool Mz3GroupData::initForTopPage(AccessTypeInfo& accessTypeInfo, const InitializeType initType)
{
	this->groups.clear();
	this->services = initType.strSelectedServices;

	// T[rX̏ꍇ͑SIƂ݂ȂST[rXǉ
	if (this->services.empty()) {
		for (size_t idx=0; idx<theApp.m_luaServices.size(); idx++) {
			this->services += " ";
			this->services += theApp.m_luaServices[idx].name;
		}
	}

	// CxgnȟĂяo
	util::CallMZ3ScriptHookFunctions("", "creating_default_group", this);

	return true;
}

/**
 * group ɃJeSǉB
 *
 * category_url  NULL ܂͋̏ꍇ́AJeSʂɉftHgURLw肷B
 * JeSʂɉJ^Cvw肷B
 */
bool Mz3GroupData::appendCategoryByIniData( 
	AccessTypeInfo& accessTypeInfo, 
	CGroupItem& group, const std::string& category_name, ACCESS_TYPE category_type, const char* category_url, bool bCruise )
{
	// ftHgURLicategory_url w̏ꍇɗpURLj
	LPCTSTR default_category_url = accessTypeInfo.getDefaultCategoryURL(category_type);

	AccessTypeInfo::BODY_INDICATE_TYPE colType1 = accessTypeInfo.getBodyHeaderCol1Type(category_type);
	AccessTypeInfo::BODY_INDICATE_TYPE colType2 = accessTypeInfo.getBodyHeaderCol2Type(category_type);
	AccessTypeInfo::BODY_INDICATE_TYPE colType3 = accessTypeInfo.getBodyHeaderCol3Type(category_type);

	if (colType1==AccessTypeInfo::BODY_INDICATE_TYPE_NONE || 
		colType2==AccessTypeInfo::BODY_INDICATE_TYPE_NONE) 
	{
		// T|[gÔߒǉI
//		MZ3LOGGER_ERROR(L"T|[gÔߒǉ܂B");
		return false;
	}

	// ANZXʕɔڍs
	switch( category_type ) {
	case ACCESS_LIST_FAVORITE_USER:
		// Cɓ胆[U
		if (category_url != NULL && strstr(category_url, "kind=community")!=NULL) {
			// uCɓR~vƂď
			category_type = ACCESS_LIST_FAVORITE_COMMUNITY;
		}
		break;
	}

	// URL w肳Ă΂ URL pB
	CString url = default_category_url;
	if( category_url!=NULL && strlen(category_url) > 0 ) {
		// `init@C̈ڍs
		if (category_type == ACCESS_LIST_FOOTSTEP &&
			strcmp(category_url, "show_log.pl")==0)
		{
			// URLAPIpURLɒu
		} else if (category_type == ACCESS_LIST_FRIEND &&
			strcmp(category_url, "list_friend.pl")==0)
		{
			// }C~NꗗURLAPIpURLɒu
		} else {	
			url = util::my_mbstowcs(category_url).c_str();
		}
	}

	static CCategoryItem item;
	item.init( 
		util::my_mbstowcs(category_name).c_str(), 
		url, 
		category_type, 
		group.categories.size(), 
		colType1, colType2, colType3 );
	item.m_bCruise = bCruise;
	group.categories.push_back( item );

	return true;
}

/**
 * L̃}bv𐶐B
 *<commit_msg>- Twitter のタイムラインを公式RTが表示できるAPIに変更(カテゴリのURL移行処理を含む)<commit_after>/*
 * Copyright (c) MZ3 Project Team All rights reserved.
 * Code licensed under the BSD License:
 * http://www.mz3.jp/license.txt
 */
#include "stdafx.h"
#include "MZ3.h"
#include "Mz3GroupData.h"
#include "util_base.h"
#include "util_mz3.h"
#include "inifile.h"

/**
 * gbvy[Wp̏
 *
 * O[vXgƂ̔z̃Xg̐B
 */
bool Mz3GroupData::initForTopPage(AccessTypeInfo& accessTypeInfo, const InitializeType initType)
{
	this->groups.clear();
	this->services = initType.strSelectedServices;

	// T[rX̏ꍇ͑SIƂ݂ȂST[rXǉ
	if (this->services.empty()) {
		for (size_t idx=0; idx<theApp.m_luaServices.size(); idx++) {
			this->services += " ";
			this->services += theApp.m_luaServices[idx].name;
		}
	}

	// CxgnȟĂяo
	util::CallMZ3ScriptHookFunctions("", "creating_default_group", this);

	return true;
}

/**
 * group ɃJeSǉB
 *
 * category_url  NULL ܂͋̏ꍇ́AJeSʂɉftHgURLw肷B
 * JeSʂɉJ^Cvw肷B
 */
bool Mz3GroupData::appendCategoryByIniData( 
	AccessTypeInfo& accessTypeInfo, 
	CGroupItem& group, const std::string& category_name, ACCESS_TYPE category_type, const char* category_url, bool bCruise )
{
	// ftHgURLicategory_url w̏ꍇɗpURLj
	LPCTSTR default_category_url = accessTypeInfo.getDefaultCategoryURL(category_type);

	AccessTypeInfo::BODY_INDICATE_TYPE colType1 = accessTypeInfo.getBodyHeaderCol1Type(category_type);
	AccessTypeInfo::BODY_INDICATE_TYPE colType2 = accessTypeInfo.getBodyHeaderCol2Type(category_type);
	AccessTypeInfo::BODY_INDICATE_TYPE colType3 = accessTypeInfo.getBodyHeaderCol3Type(category_type);

	if (colType1==AccessTypeInfo::BODY_INDICATE_TYPE_NONE || 
		colType2==AccessTypeInfo::BODY_INDICATE_TYPE_NONE) 
	{
		// T|[gÔߒǉI
//		MZ3LOGGER_ERROR(L"T|[gÔߒǉ܂B");
		return false;
	}

	// ANZXʕɔڍs
	switch( category_type ) {
	case ACCESS_LIST_FAVORITE_USER:
		// Cɓ胆[U
		if (category_url != NULL && strstr(category_url, "kind=community")!=NULL) {
			// uCɓR~vƂď
			category_type = ACCESS_LIST_FAVORITE_COMMUNITY;
		}
		break;
	}

	// URL w肳Ă΂ URL pB
	CString url = default_category_url;
	if( category_url!=NULL && strlen(category_url) > 0 ) {
		// `init@C̈ڍs
		if (category_type == ACCESS_LIST_FOOTSTEP && strcmp(category_url, "show_log.pl")==0) {
			// URLAPIpURLɒu(ftHgURL̗p)
		} else if (category_type == ACCESS_LIST_FRIEND && strcmp(category_url, "list_friend.pl")==0) {
			// }C~NꗗURLAPIpURLɒu(ftHgURL̗p)
		} else if (category_type == ACCESS_TWITTER_FRIENDS_TIMELINE &&
			       strstr(category_url, "http://twitter.com/statuses/friends_timeline.xml")!=NULL)
		{
			// friends_timeline.xml  home_timeline.xml ɏ
			CString strCategoryUrl(category_url);
			strCategoryUrl.Replace(L"http://twitter.com/statuses/friends_timeline.xml",
								   L"http://twitter.com/statuses/home_timeline.xml");
			url = strCategoryUrl;
		} else {
			// JeSURL̗p
			url = util::my_mbstowcs(category_url).c_str();
		}
	}

	static CCategoryItem item;
	item.init( 
		util::my_mbstowcs(category_name).c_str(), 
		url, 
		category_type, 
		group.categories.size(), 
		colType1, colType2, colType3 );
	item.m_bCruise = bCruise;
	group.categories.push_back( item );

	return true;
}

/**
 * L̃}bv𐶐B
 *
{'fraction_non_alphanumeric': 0.13911845730027547, 'fraction_numerical': 0.008264462809917356, 'mean_word_length': 4.951844262295082, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '739048', 'n_tokens_mistral': 2599, 'n_tokens_neox': 2484, 'n_words': 338}