summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/variables.cpp
blob: e3b7eabedc0b44b0ef35d40b078eb0935afe49ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//fürs varaibles händling - dufte
#include "stdafx.h"

#include "variables.h"

extern HANDLE XFireWorkingFolder, XFireIconFolder, XFireAvatarFolder;

using namespace std;

char* Varxfiregame(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	if (ai->fi->hContact == NULL) {
		//
	}
	else {
		char temp[256];
		DBVARIANT dbv3;
		if (!db_get(ai->fi->hContact, protocolname, "RGame", &dbv3)) {
			strncpy(temp, dbv3.pszVal, 255);
			db_free(&dbv3);
			return mir_strdup(temp);
		}
	}

	ai->flags = AIF_FALSE;
	return mir_strdup("");
}

char* Varmyxfiregame(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	DBVARIANT dbv3;
	if (!db_get(NULL, protocolname, "currentgamename", &dbv3)) {
		char* ret = mir_strdup(dbv3.pszVal);
		db_free(&dbv3);
		return ret;
	}
	ai->flags = AIF_FALSE;
	return mir_strdup("");
}

char* Varxfirevoice(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	DBVARIANT dbv3;
	if (!db_get(ai->fi->hContact, protocolname, "RVoice", &dbv3)) {
		char* ret = mir_strdup(dbv3.pszVal);
		db_free(&dbv3);
		return ret;
	}

	ai->flags = AIF_FALSE;
	return mir_strdup("");
}


char* Varmyxfirevoiceip(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	DBVARIANT dbv3;
	if (!db_get(NULL, protocolname, "VServerIP", &dbv3)) {
		char* ret = mir_strdup(dbv3.pszVal);
		db_free(&dbv3);
		return ret;
	}

	ai->flags = AIF_FALSE;
	return mir_strdup("");
}

char* Varmyxfireserverip(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	DBVARIANT dbv3;
	if (!db_get(NULL, protocolname, "ServerIP", &dbv3)) {
		char* ret = mir_strdup(dbv3.pszVal);
		db_free(&dbv3);
		return ret;
	}

	ai->flags = AIF_FALSE;
	return mir_strdup("");
}

char* Varxfireserverip(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	if (ai->fi->hContact != NULL) {
		char temp[24];
		DBVARIANT dbv3;
		if (!db_get(ai->fi->hContact, protocolname, "ServerIP", &dbv3)) {
			mir_snprintf(temp, _countof(temp), "%s:%d", dbv3.pszVal, db_get_w(ai->fi->hContact, protocolname, "Port", 0));
			db_free(&dbv3);
			return mir_strdup(temp);
		}
	}

	ai->flags = AIF_FALSE;
	return mir_strdup("");
}

char* Varxfirevoiceip(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	if (ai->fi->hContact == NULL) {
		ai->flags = AIF_FALSE;
		return mir_strdup("");
	}
	else {
		char temp[24];
		DBVARIANT dbv3;
		if (!db_get(ai->fi->hContact, protocolname, "VServerIP", &dbv3)) {
			mir_snprintf(temp, _countof(temp), "%s:%d", dbv3.pszVal, db_get_w(ai->fi->hContact, protocolname, "VPort", 0));
			db_free(&dbv3);
			return mir_strdup(temp);
		}
		ai->flags = AIF_FALSE;
		return mir_strdup("");
	}
}

char* Varmyxfirevoice(ARGUMENTSINFO *ai)
{
	if (ai->cbSize < sizeof(ARGUMENTSINFO))
		return NULL;

	DBVARIANT dbv3;
	if (!db_get(NULL, protocolname, "currentvoicename", &dbv3)) {
		char* ret = mir_strdup(dbv3.pszVal);
		db_free(&dbv3);
		return ret;
	}

	return mir_strdup("");
}

char* XFireGetFoldersPath(char * pathtype)
{// Get XFire folder path
	static char path[1024]; path[0] = 0;
	if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
		if (!mir_strcmp(pathtype, "Avatar")) {
			FoldersGetCustomPath(XFireAvatarFolder, path, 1024, "");
		}
		if (!mir_strcmp(pathtype, "IniFile")) {
			FoldersGetCustomPath(XFireWorkingFolder, path, 1024, "");
		}
		if (!mir_strcmp(pathtype, "IconsFile")) {
			FoldersGetCustomPath(XFireIconFolder, path, 1024, "");
		}
		mir_strcat(path, "\\");
		return path;
	}
	else {
		/******BASE********/
		char BaseFolder[MAX_PATH] = "";
		char CurProfileF[MAX_PATH] = "";
		char CurProfile[MAX_PATH] = "";
		CallService(MS_DB_GETPROFILEPATH, (WPARAM)MAX_PATH, (LPARAM)BaseFolder);
		mir_strcat(BaseFolder, "\\");
		CallService(MS_DB_GETPROFILENAME, (WPARAM)MAX_PATH, (LPARAM)CurProfileF);
		int i;
		for (i = MAX_PATH - 1; i > 5; i--) {
			if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.') {
				i -= 3;
				break;
			}
		}
		memcpy(CurProfile, CurProfileF, i);
		mir_strcat(BaseFolder, CurProfile);
		mir_strcat(BaseFolder, "\\");
		mir_strcat(BaseFolder, "XFire");
		mir_strcat(BaseFolder, "\\");
		/*******BASE********/
		if (!mir_strcmp(pathtype, "Avatar")) {
			mir_strcat(BaseFolder, "Avatars");
			mir_strcat(BaseFolder, "\\");
		}
		mir_strcat(path, BaseFolder);
	}
	return path;
}