Subversion Repositories spk

Rev

Rev 170 | Rev 191 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 170 Rev 187
Line 1... Line 1...
1
#include <spk.h>
1
#include <spk.h>
-
 
2
#include "Utils/WString.h"
2
 
3
 
3
using namespace System;
4
using namespace System;
4
using namespace Runtime::InteropServices;
5
using namespace Runtime::InteropServices;
5
using namespace System::Drawing;
6
using namespace System::Drawing;
6
 
7
 
7
#define CONNECTERROR_UNKNOWN	-1
8
#define CONNECTERROR_UNKNOWN	-1
8
enum {CONNECTERROR_NONE, CONNECTERROR_TIMEOUT, CONNECTERROR_NOFILE, CONNECTERROR_FAILED};
9
enum {CONNECTERROR_NONE, CONNECTERROR_TIMEOUT, CONNECTERROR_NOFILE, CONNECTERROR_FAILED};
9
 
10
 
10
inline Utils::String _S(System::String ^str)
11
inline Utils::String _S(System::String^ str)
11
{
12
{
12
	if ( !str || !str->Length )
13
	if (!str || !str->Length)
13
		return "";
14
		return "";
14
	const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(str)).ToPointer();
15
	const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(str)).ToPointer();
15
	std::string s = chars;
16
	std::string s = chars;
-
 
17
	Marshal::FreeHGlobal(IntPtr((void*)chars));
-
 
18
	return s;
-
 
19
}
-
 
20
inline Utils::WString _WS(System::String^ str)
-
 
21
{
-
 
22
	if (!str || !str->Length)
-
 
23
		return L"";
-
 
24
	const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni(str)).ToPointer();
-
 
25
	std::wstring s = chars;
16
	Marshal::FreeHGlobal(IntPtr((void*)chars));
26
	Marshal::FreeHGlobal(IntPtr((void*)chars));
17
	return s;
27
	return s;
18
}
28
}
19
inline CyString CyStringFromSystemString( System::String ^str)
29
inline CyString CyStringFromSystemString( System::String ^str)
20
{
30
{
Line 29... Line 39...
29
}
39
}
30
 
40
 
31
inline int CheckWebFileExists(String ^url)
41
inline int CheckWebFileExists(String ^url)
32
{
42
{
33
	int ret = CONNECTERROR_UNKNOWN;
43
	int ret = CONNECTERROR_UNKNOWN;
34
	try 
44
	try 
35
	{
45
	{
36
		// check for the file
46
		// check for the file
37
		Net::WebRequest ^check = (Net::HttpWebRequest ^)Net::WebRequest::Create(url);
47
		Net::WebRequest ^check = (Net::HttpWebRequest ^)Net::WebRequest::Create(url);
38
		check->Credentials = Net::CredentialCache::DefaultCredentials;
48
		check->Credentials = Net::CredentialCache::DefaultCredentials;
39
		Net::WebResponse ^response = (Net::HttpWebResponse ^)check->GetResponse();
49
		Net::WebResponse ^response = (Net::HttpWebResponse ^)check->GetResponse();
40
		// check the file size
50
		// check the file size
41
		__int64 fileSize = response->ContentLength;
51
		__int64 fileSize = response->ContentLength;
42
		if ( fileSize )
52
		if ( fileSize )
43
			ret = CONNECTERROR_NONE;
53
			ret = CONNECTERROR_NONE;
44
 
54
 
45
		response->Close();
55
		response->Close();
46
 
56
 
47
	}
57
	}
48
	catch (System::Net::WebException ^ex)
58
	catch (System::Net::WebException ^ex)
49
	{
59
	{
50
		if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
60
		if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
51
			ret = CONNECTERROR_FAILED;
61
			ret = CONNECTERROR_FAILED;
Line 98... Line 108...
98
inline System::String ^SystemStringFromCyString ( CyString str )
108
inline System::String ^SystemStringFromCyString ( CyString str )
99
{
109
{
100
	System::String ^Str = gcnew System::String(str.c_str());
110
	System::String ^Str = gcnew System::String(str.c_str());
101
	return Str;
111
	return Str;
102
}
112
}
-
 
113
 
103
inline System::String ^_US(const Utils::String &str)
114
inline System::String^ _US(const Utils::WString& str)
104
{
115
{
105
	System::String ^Str = gcnew System::String(str.c_str());
116
	System::String^ Str = gcnew System::String(str.c_str());
106
	return Str;
117
	return Str;
107
}
118
}
108
 
119
 
109
inline System::Drawing::Bitmap ^LoadIcon(CBaseFile *p)
120
inline System::Drawing::Bitmap ^LoadIcon(CBaseFile *p)
110
{
121
{