Project

General

Profile

Download (15.7 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / scores / RubikScoresDownloader.java @ fb377dae

1 fdec60a3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 f0e87514 Leszek Koltunski
package org.distorted.scores;
21 fdec60a3 Leszek Koltunski
22 1780dcb0 Leszek Koltunski
import android.content.pm.PackageInfo;
23
import android.content.pm.PackageManager;
24
25 66e777b0 Leszek Koltunski
import androidx.fragment.app.FragmentActivity;
26 4895fff6 Leszek Koltunski
27 1f9772f3 Leszek Koltunski
import org.distorted.objects.RubikObjectList;
28 4888e97c Leszek Koltunski
29 36e2cbdd Leszek Koltunski
import java.io.InputStream;
30
import java.net.HttpURLConnection;
31
import java.net.URL;
32 cc5ec229 Leszek Koltunski
import java.net.UnknownHostException;
33 86cbdab1 Leszek Koltunski
import java.security.MessageDigest;
34
import java.security.NoSuchAlgorithmException;
35 36e2cbdd Leszek Koltunski
36 8e3898c8 Leszek Koltunski
import static org.distorted.objects.RubikObjectList.MAX_LEVEL;
37 211b48f2 Leszek Koltunski
38 fdec60a3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40 211b48f2 Leszek Koltunski
public class RubikScoresDownloader implements Runnable
41 fdec60a3 Leszek Koltunski
  {
42 211b48f2 Leszek Koltunski
  public interface Receiver
43 b8b38548 Leszek Koltunski
    {
44 1c90c64a Leszek Koltunski
    void receive(String[][][] country, String[][][] name, float[][][] time);
45 4895fff6 Leszek Koltunski
    void message(String mess);
46 4c0cd600 Leszek Koltunski
    void error(String error);
47 b8b38548 Leszek Koltunski
    }
48
49 286d73ae Leszek Koltunski
  public static final int MAX_PLACES = 10;
50 d8aa4ba8 Leszek Koltunski
51 b8b38548 Leszek Koltunski
  private static final int DOWNLOAD   = 0;
52
  private static final int SUBMIT     = 1;
53
  private static final int IDLE       = 2;
54
55 36e2cbdd Leszek Koltunski
  private final String[] hex = {
56
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
57
    "%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f",
58
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
59
    "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f",
60
    "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27",
61
    "%28", "%29", "%2a", "%2b", "%2c", "%2d", "%2e", "%2f",
62
    "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37",
63
    "%38", "%39", "%3a", "%3b", "%3c", "%3d", "%3e", "%3f",
64
    "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47",
65
    "%48", "%49", "%4a", "%4b", "%4c", "%4d", "%4e", "%4f",
66
    "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57",
67
    "%58", "%59", "%5a", "%5b", "%5c", "%5d", "%5e", "%5f",
68
    "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67",
69
    "%68", "%69", "%6a", "%6b", "%6c", "%6d", "%6e", "%6f",
70
    "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77",
71
    "%78", "%79", "%7a", "%7b", "%7c", "%7d", "%7e", "%7f",
72
    "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87",
73
    "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f",
74
    "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97",
75
    "%98", "%99", "%9a", "%9b", "%9c", "%9d", "%9e", "%9f",
76
    "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",
77
    "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", "%ae", "%af",
78
    "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7",
79
    "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf",
80
    "%c0", "%c1", "%c2", "%c3", "%c4", "%c5", "%c6", "%c7",
81
    "%c8", "%c9", "%ca", "%cb", "%cc", "%cd", "%ce", "%cf",
82
    "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
83
    "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df",
84
    "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7",
85
    "%e8", "%e9", "%ea", "%eb", "%ec", "%ed", "%ee", "%ef",
86
    "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
87
    "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", "%fe", "%ff"
88
    };
89
90 b8b38548 Leszek Koltunski
  private static boolean mRunning = false;
91
  private static int mMode = IDLE;
92
  private static Receiver mReceiver;
93 4895fff6 Leszek Koltunski
  private static String mVersion;
94 b8b38548 Leszek Koltunski
95 4888e97c Leszek Koltunski
  private static int mTotal = RubikObjectList.getTotal();
96 f3e12931 Leszek Koltunski
  private static String mScores = "";
97 85b09df4 Leszek Koltunski
  private static String[][][] mCountry = new String[mTotal][MAX_LEVEL][MAX_PLACES];
98
  private static String[][][] mName    = new String[mTotal][MAX_LEVEL][MAX_PLACES];
99
  private static  float[][][] mTime    = new  float[mTotal][MAX_LEVEL][MAX_PLACES];
100 f3e12931 Leszek Koltunski
101 85b09df4 Leszek Koltunski
  private static int[][] mPlaces = new int[mTotal][MAX_LEVEL];
102 bc511ea5 Leszek Koltunski
  private static RubikScoresDownloader mThis;
103 329c0aeb Leszek Koltunski
104 4895fff6 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
105
106 86cbdab1 Leszek Koltunski
  private static String computeHash(String stringToHash, byte[] salt)
107 4895fff6 Leszek Koltunski
    {
108 86cbdab1 Leszek Koltunski
    String generatedPassword;
109
110
    try
111
      {
112
      MessageDigest md = MessageDigest.getInstance("MD5");
113
      md.update(salt);
114
      byte[] bytes = md.digest(stringToHash.getBytes());
115
      StringBuilder sb = new StringBuilder();
116
117
      for (byte aByte : bytes)
118
        {
119
        sb.append(Integer.toString((aByte & 0xff) + 0x100, 16).substring(1));
120
        }
121
122
      generatedPassword = sb.toString();
123
      }
124
    catch (NoSuchAlgorithmException e)
125
      {
126
      return "NoSuchAlgorithm";
127
      }
128
129
    return generatedPassword;
130 4895fff6 Leszek Koltunski
    }
131
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133
134 17f9a695 Leszek Koltunski
  private boolean fillValues()
135 f3e12931 Leszek Koltunski
    {
136 d8aa4ba8 Leszek Koltunski
    int begin=-1 ,end, len = mScores.length();
137 17f9a695 Leszek Koltunski
    String row;
138 f3e12931 Leszek Koltunski
139 4c0cd600 Leszek Koltunski
    if( len==0 )
140
      {
141
      mReceiver.error("1");
142
      return false;
143
      }
144 90fd47b0 Leszek Koltunski
    else if( len<=2 )
145 4c0cd600 Leszek Koltunski
      {
146
      mReceiver.error(mScores);
147
      return false;
148
      }
149
150 4888e97c Leszek Koltunski
    for(int i=0; i<mTotal; i++)
151 85b09df4 Leszek Koltunski
      for(int j=0; j<MAX_LEVEL; j++)
152 329c0aeb Leszek Koltunski
        {
153
        mPlaces[i][j] = 0;
154
        }
155
156 d8aa4ba8 Leszek Koltunski
    while( begin<len )
157
      {
158
      end = mScores.indexOf('\n', begin+1);
159
      if( end<0 ) end = len;
160 286d73ae Leszek Koltunski
161
      try
162
        {
163 17f9a695 Leszek Koltunski
        row = mScores.substring(begin+1,end);
164 4c0cd600 Leszek Koltunski
        fillRow(row);
165 286d73ae Leszek Koltunski
        }
166
      catch(Exception ex)
167
        {
168
        // faulty row - ignore
169
        }
170
171 d8aa4ba8 Leszek Koltunski
      begin = end;
172
      }
173 17f9a695 Leszek Koltunski
174
    return true;
175 f3e12931 Leszek Koltunski
    }
176
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178
179 d8aa4ba8 Leszek Koltunski
  private void fillRow(String row)
180 f3e12931 Leszek Koltunski
    {
181 d8aa4ba8 Leszek Koltunski
    int s1 = row.indexOf(' ');
182
    int s2 = row.indexOf(' ',s1+1);
183
    int s3 = row.indexOf(' ',s2+1);
184
    int s4 = row.indexOf(' ',s3+1);
185 286d73ae Leszek Koltunski
    int s5 = row.length();
186 d8aa4ba8 Leszek Koltunski
187
    if( s5>s4 && s4>s3 && s3>s2 && s2>s1 && s1>0 )
188
      {
189 286d73ae Leszek Koltunski
      int object = RubikObjectList.unpackObjectFromString( row.substring(0,s1) );
190 b8b38548 Leszek Koltunski
191 286d73ae Leszek Koltunski
      if( object>=0 && object<mTotal )
192 d8aa4ba8 Leszek Koltunski
        {
193 8e3898c8 Leszek Koltunski
        int level      = Integer.parseInt( row.substring(s1+1,s2) );
194 286d73ae Leszek Koltunski
        String name    = row.substring(s2+1, s3);
195
        int time       = Integer.parseInt( row.substring(s3+1,s4) );
196
        String country = row.substring(s4+1, s5);
197 d8aa4ba8 Leszek Koltunski
198 8e3898c8 Leszek Koltunski
        if(level>=0 && level<MAX_LEVEL)
199 d8aa4ba8 Leszek Koltunski
          {
200 8e3898c8 Leszek Koltunski
          int p = mPlaces[object][level];
201
          mPlaces[object][level]++;
202 329c0aeb Leszek Koltunski
203 8e3898c8 Leszek Koltunski
          mCountry[object][level][p] = country;
204
          mName   [object][level][p] = name;
205 79e752b3 Leszek Koltunski
          mTime   [object][level][p] = ((float)(time/10))/100.0f;
206 d8aa4ba8 Leszek Koltunski
          }
207
        }
208
      }
209 874c37b1 Leszek Koltunski
    else
210
      {
211 5d50e7a7 Leszek Koltunski
      tryDoCommand(row);
212
      }
213
    }
214
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216
217
  private void tryDoCommand(String row)
218
    {
219
    if( row.startsWith("comm") )
220
      {
221
      int colon = row.indexOf(':');
222
223
      if( colon>0 )
224 874c37b1 Leszek Koltunski
        {
225 5d50e7a7 Leszek Koltunski
        String commandNumber = row.substring(4,colon);
226
        int number;
227
228
        try
229
          {
230
          number = Integer.parseInt(commandNumber);
231
          }
232
        catch(NumberFormatException ex)
233
          {
234
          number=0;
235
          }
236 874c37b1 Leszek Koltunski
237 5d50e7a7 Leszek Koltunski
        if(number==1)
238 874c37b1 Leszek Koltunski
          {
239
          String country = row.substring(colon+1);
240
          RubikScores scores = RubikScores.getInstance();
241
          scores.setCountry(country);
242
          }
243
        }
244
      }
245 f3e12931 Leszek Koltunski
    }
246
247 36e2cbdd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
248
249
  private String URLencode(String s)
250
    {
251
    StringBuilder sbuf = new StringBuilder();
252
    int len = s.length();
253
254
    for (int i = 0; i < len; i++)
255
      {
256
      int ch = s.charAt(i);
257
258
           if ('A' <= ch && ch <= 'Z') sbuf.append((char)ch);
259
      else if ('a' <= ch && ch <= 'z') sbuf.append((char)ch);
260
      else if ('0' <= ch && ch <= '9') sbuf.append((char)ch);
261
      else if (ch == ' '             ) sbuf.append('+');
262
      else if (ch == '-' || ch == '_'
263
            || ch == '.' || ch == '!'
264
            || ch == '~' || ch == '*'
265
            || ch == '\'' || ch == '('
266
            || ch == ')'             ) sbuf.append((char)ch);
267
      else if (ch <= 0x007f)           sbuf.append(hex[ch]);
268
      else if (ch <= 0x07FF)
269
        {
270
        sbuf.append(hex[0xc0 | (ch >> 6)]);
271
        sbuf.append(hex[0x80 | (ch & 0x3F)]);
272
        }
273
      else
274
        {
275
        sbuf.append(hex[0xe0 | (ch >> 12)]);
276
        sbuf.append(hex[0x80 | ((ch >> 6) & 0x3F)]);
277
        sbuf.append(hex[0x80 | (ch & 0x3F)]);
278
        }
279
      }
280
281
    return sbuf.toString();
282
    }
283
284 f3e12931 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
285
286 4895fff6 Leszek Koltunski
  private boolean network(String url)
287 f3e12931 Leszek Koltunski
    {
288 4c0cd600 Leszek Koltunski
    //android.util.Log.e("down", "url: "+url);
289 36e2cbdd Leszek Koltunski
290
    try
291
      {
292 4895fff6 Leszek Koltunski
      java.net.URL connectURL = new URL(url);
293 36e2cbdd Leszek Koltunski
      HttpURLConnection conn = (HttpURLConnection)connectURL.openConnection();
294
295
      conn.setDoInput(true);
296
      conn.setDoOutput(true);
297
      conn.setUseCaches(false);
298
      conn.setRequestMethod("GET");
299
      conn.connect();
300
      conn.getOutputStream().flush();
301
302 a675474f Leszek Koltunski
      try( InputStream is = conn.getInputStream() )
303 36e2cbdd Leszek Koltunski
        {
304
        int ch;
305
        StringBuilder sb = new StringBuilder();
306
        while( ( ch = is.read() ) != -1 )
307
          {
308
          sb.append( (char)ch );
309
          }
310
        mScores = sb.toString();
311
        }
312 cc5ec229 Leszek Koltunski
      catch( final Exception e)
313 36e2cbdd Leszek Koltunski
        {
314 4895fff6 Leszek Koltunski
        mReceiver.message("Failed to get an answer from the High Scores server");
315 a675474f Leszek Koltunski
        return false;
316 36e2cbdd Leszek Koltunski
        }
317
      }
318 cc5ec229 Leszek Koltunski
    catch( final UnknownHostException e )
319
      {
320 4895fff6 Leszek Koltunski
      mReceiver.message("No access to Internet");
321 cc5ec229 Leszek Koltunski
      return false;
322
      }
323
    catch( final SecurityException e )
324
      {
325 4895fff6 Leszek Koltunski
      mReceiver.message("Application not authorized to connect to the Internet");
326 cc5ec229 Leszek Koltunski
      return false;
327
      }
328
    catch( final Exception e )
329 36e2cbdd Leszek Koltunski
      {
330 4895fff6 Leszek Koltunski
      mReceiver.message(e.getMessage());
331 a675474f Leszek Koltunski
      return false;
332 36e2cbdd Leszek Koltunski
      }
333
334 329c0aeb Leszek Koltunski
    if( mScores.length()==0 )
335
      {
336 4895fff6 Leszek Koltunski
      mReceiver.message("Failed to download scores");
337 329c0aeb Leszek Koltunski
      return false;
338
      }
339
340 a675474f Leszek Koltunski
    return true;
341 b8b38548 Leszek Koltunski
    }
342 d8aa4ba8 Leszek Koltunski
343 17f9a695 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
344
345
  private String constructDownloadURL()
346
    {
347
    RubikScores scores = RubikScores.getInstance();
348
    String name = URLencode(scores.getName());
349
    String veri = scores.isVerified() ? name : "";
350
    int numRuns = scores.getNumRuns();
351
    int numPlay = scores.getNumPlays();
352 874c37b1 Leszek Koltunski
    String country = scores.getCountry();
353 17f9a695 Leszek Koltunski
354
    String url="https://distorted.org/magic/cgi-bin/download.cgi";
355 874c37b1 Leszek Koltunski
    url += "?n="+name+"&v="+veri+"&r="+numRuns+"&p="+numPlay+"&c="+country+"&e="+mVersion+"d";
356 85b09df4 Leszek Koltunski
    url += "&o="+RubikObjectList.getObjectList()+"&min=0&max="+MAX_LEVEL+"&l="+MAX_PLACES;
357 17f9a695 Leszek Koltunski
358
    return url;
359
    }
360
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362
363
  private String constructSubmitURL()
364
    {
365
    RubikScores scores = RubikScores.getInstance();
366
    String name = URLencode(scores.getName());
367
    String veri = scores.isVerified() ? name : "";
368
    int numRuns = scores.getNumRuns();
369
    int numPlay = scores.getNumPlays();
370
    int deviceID= scores.getDeviceID();
371
    String objlist = scores.getUnsubmittedObjlist();
372
    String lvllist = scores.getUnsubmittedLevellist();
373
    String timlist = scores.getUnsubmittedTimelist();
374
    String country = scores.getCountry();
375 86cbdab1 Leszek Koltunski
    long epoch = System.currentTimeMillis();
376 fb377dae Leszek Koltunski
    String salt = "cuboid";
377 17f9a695 Leszek Koltunski
378 86cbdab1 Leszek Koltunski
    String url1="https://distorted.org/magic/cgi-bin/submit.cgi";
379
    String url2 = "n="+name+"&v="+veri+"&r="+numRuns+"&p="+numPlay+"&i="+deviceID+"&e="+mVersion+"d";
380
    url2 += "&o="+objlist+"&l="+lvllist+"&t="+timlist+"&c="+country+"&f="+epoch;
381
    url2 += "&oo="+RubikObjectList.getObjectList()+"&min=0&max="+MAX_LEVEL+"&lo="+MAX_PLACES;
382 fb377dae Leszek Koltunski
    url2 += "&h="+computeHash( url2, salt.getBytes() );
383 17f9a695 Leszek Koltunski
384 86cbdab1 Leszek Koltunski
    return url1 + "?" + url2;
385 17f9a695 Leszek Koltunski
    }
386
387 d8aa4ba8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
388
389
  private boolean gottaDownload()
390 b8b38548 Leszek Koltunski
    {
391 d8aa4ba8 Leszek Koltunski
    return ((mScores.length()==0) && !mRunning);
392 f3e12931 Leszek Koltunski
    }
393 b8b38548 Leszek Koltunski
394 d8aa4ba8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
395
396 4f9f99a2 Leszek Koltunski
  @Override
397 d8aa4ba8 Leszek Koltunski
  public void run()
398
    {
399 a675474f Leszek Koltunski
    boolean success=true;
400
401 17f9a695 Leszek Koltunski
    try
402 d8aa4ba8 Leszek Koltunski
      {
403 17f9a695 Leszek Koltunski
      if( mMode==DOWNLOAD && gottaDownload() )
404 d8aa4ba8 Leszek Koltunski
        {
405 17f9a695 Leszek Koltunski
        mRunning = true;
406
        success = network(constructDownloadURL());
407 d8aa4ba8 Leszek Koltunski
        }
408 17f9a695 Leszek Koltunski
      if( mMode==SUBMIT )
409 4895fff6 Leszek Koltunski
        {
410 17f9a695 Leszek Koltunski
        mRunning = true;
411 4895fff6 Leszek Koltunski
412 17f9a695 Leszek Koltunski
        if( RubikScores.getInstance().thereAreUnsubmittedRecords() )
413
          {
414
          success = network(constructSubmitURL());
415
          }
416
        }
417 d8aa4ba8 Leszek Koltunski
      }
418 17f9a695 Leszek Koltunski
    catch( Exception e )
419 d8aa4ba8 Leszek Koltunski
      {
420 17f9a695 Leszek Koltunski
      mReceiver.message("Exception downloading records: "+e.getMessage() );
421 4895fff6 Leszek Koltunski
      }
422 286d73ae Leszek Koltunski
423 17f9a695 Leszek Koltunski
    if( mRunning )
424
      {
425
      success = fillValues();
426
      mRunning = false;
427
      }
428 a675474f Leszek Koltunski
429
    if( success )
430
      {
431 cc5ec229 Leszek Koltunski
      mReceiver.receive(mCountry, mName, mTime);
432 17f9a695 Leszek Koltunski
433
      if( mMode==SUBMIT )
434
        {
435
        RubikScores.getInstance().successfulSubmit();
436
        }
437 a675474f Leszek Koltunski
      }
438 d8aa4ba8 Leszek Koltunski
    }
439 4f9f99a2 Leszek Koltunski
440 bc511ea5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
441
442
  private RubikScoresDownloader()
443
    {
444
445
    }
446
447 4f9f99a2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
448
// PUBLIC API
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450
451
  public static void onPause()
452
    {
453
    mRunning = false;
454
    }
455
456 bc511ea5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
457
458
  public static RubikScoresDownloader getInstance()
459
    {
460
    if( mThis==null )
461
      {
462
      mThis = new RubikScoresDownloader();
463
      }
464
465
    return mThis;
466
    }
467
468 4f9f99a2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
469
470 1780dcb0 Leszek Koltunski
  private void start(Receiver receiver, FragmentActivity act, int mode)
471 4f9f99a2 Leszek Koltunski
    {
472
    mReceiver = receiver;
473 1780dcb0 Leszek Koltunski
    mMode     = mode;
474
475
    try
476
      {
477
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
478
      mVersion = pInfo.versionName;
479
      }
480
    catch (PackageManager.NameNotFoundException e)
481
      {
482 4fd84652 Leszek Koltunski
      mVersion = "1.1.2";
483 1780dcb0 Leszek Koltunski
      }
484 6f8e5dfc Leszek Koltunski
485 4f9f99a2 Leszek Koltunski
    Thread networkThrd = new Thread(this);
486
    networkThrd.start();
487
    }
488 bc511ea5 Leszek Koltunski
489
///////////////////////////////////////////////////////////////////////////////////////////////////
490
491 1780dcb0 Leszek Koltunski
  public void download(Receiver receiver, FragmentActivity act)
492 bc511ea5 Leszek Koltunski
    {
493 1780dcb0 Leszek Koltunski
    start(receiver, act, DOWNLOAD);
494
    }
495 bc511ea5 Leszek Koltunski
496 1780dcb0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
497
498
  public void submit(Receiver receiver, FragmentActivity act)
499
    {
500
    start(receiver, act, SUBMIT);
501 bc511ea5 Leszek Koltunski
    }
502 b8b38548 Leszek Koltunski
}