Mercurial > projects > dwt-win
comparison dwt/dnd/URLTransfer.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 184ab53b7785 |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
43 * </code></pre> | 43 * </code></pre> |
44 */ | 44 */ |
45 /*public*/ class URLTransfer : ByteArrayTransfer { | 45 /*public*/ class URLTransfer : ByteArrayTransfer { |
46 | 46 |
47 static URLTransfer _instance; | 47 static URLTransfer _instance; |
48 static const char[] CFSTR_INETURL = "UniformResourceLocator"; //$NON-NLS-1$ | 48 static const String CFSTR_INETURL = "UniformResourceLocator"; //$NON-NLS-1$ |
49 static const int CFSTR_INETURLID; | 49 static const int CFSTR_INETURLID; |
50 | 50 |
51 static this(){ | 51 static this(){ |
52 CFSTR_INETURLID = registerType(CFSTR_INETURL); | 52 CFSTR_INETURLID = registerType(CFSTR_INETURL); |
53 } | 53 } |
83 if (!checkURL(object) || !isSupportedType(transferData)) { | 83 if (!checkURL(object) || !isSupportedType(transferData)) { |
84 DND.error(DND.ERROR_INVALID_DATA); | 84 DND.error(DND.ERROR_INVALID_DATA); |
85 } | 85 } |
86 transferData.result = COM.E_FAIL; | 86 transferData.result = COM.E_FAIL; |
87 // URL is stored as a null terminated byte array | 87 // URL is stored as a null terminated byte array |
88 char[] url = (cast(ArrayWrapperString2)object).array[0]; | 88 String url = (cast(ArrayWrapperString2)object).array[0]; |
89 int codePage = OS.GetACP(); | 89 int codePage = OS.GetACP(); |
90 wchar[] chars = StrToWCHARs(codePage, url, true ); | 90 wchar[] chars = StrToWCHARs(codePage, url, true ); |
91 int cchMultiByte = OS.WideCharToMultiByte(codePage, 0, chars.ptr, -1, null, 0, null, null); | 91 int cchMultiByte = OS.WideCharToMultiByte(codePage, 0, chars.ptr, -1, null, 0, null, null); |
92 if (cchMultiByte is 0) { | 92 if (cchMultiByte is 0) { |
93 transferData.stgmedium = new STGMEDIUM(); | 93 transferData.stgmedium = new STGMEDIUM(); |
145 | 145 |
146 protected int[] getTypeIds(){ | 146 protected int[] getTypeIds(){ |
147 return [CFSTR_INETURLID]; | 147 return [CFSTR_INETURLID]; |
148 } | 148 } |
149 | 149 |
150 protected char[][] getTypeNames(){ | 150 protected String[] getTypeNames(){ |
151 return [CFSTR_INETURL]; | 151 return [CFSTR_INETURL]; |
152 } | 152 } |
153 | 153 |
154 bool checkURL(Object object) { | 154 bool checkURL(Object object) { |
155 if( auto s = cast(ArrayWrapperString2)object ){ | 155 if( auto s = cast(ArrayWrapperString2)object ){ |
156 if( s.array.length is 0 ) return false; | 156 if( s.array.length is 0 ) return false; |
157 char[][] strings = s.array; | 157 String[] strings = s.array; |
158 if (strings[0] is null || strings[0].length is 0) return false; | 158 if (strings[0] is null || strings[0].length is 0) return false; |
159 //PORTING_FIXME: how to validata URL? | 159 //PORTING_FIXME: how to validata URL? |
160 /+try { | 160 /+try { |
161 new URL(strings[0]); | 161 new URL(strings[0]); |
162 } catch (java.net.MalformedURLException e) { | 162 } catch (java.net.MalformedURLException e) { |