rhodes 3.0.0 → 3.0.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +9 -2
- data/doc/application.txt +1 -1
- data/doc/build.txt +49 -70
- data/doc/device-caps.txt +22 -97
- data/doc/extensions.txt +1 -1
- data/doc/nfc.txt +542 -0
- data/doc/rhom.txt +7 -5
- data/doc/simulator.txt +116 -0
- data/doc/ui.txt +1 -1
- data/lib/build/jake.rb +5 -5
- data/lib/extensions/debugger/debugger.rb +63 -35
- data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +8 -6
- data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +1070 -249
- data/lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml +1 -5
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +894 -72
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java +82 -18
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java +65 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java +88 -24
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java +3 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +204 -3
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +1047 -5
- data/lib/extensions/nfc/nfc.rb +635 -91
- data/lib/extensions/rhoxml/rexml/encodings/CP-1252.rb +103 -0
- data/lib/extensions/rhoxml/rexml/encodings/ISO-8859-1.rb +7 -0
- data/lib/framework/dateME.rb +26 -0
- data/lib/framework/rho/render.rb +21 -9
- data/lib/framework/rho/rho.rb +12 -0
- data/lib/framework/rho/rhoevent_bb.rb +3 -0
- data/lib/framework/rho/rhoevent_c.rb +3 -0
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhom/rhom_db_adapter.rb +9 -9
- data/lib/framework/rhosystem.rb +17 -0
- data/lib/framework/stringio.rb +18 -0
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/res/xml/filter_nfc.xml +1 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +0 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +10 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +29 -18
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +67 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityListener.java +14 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +102 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +35 -66
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +5 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +69 -41
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +7 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +68 -35
- data/platform/android/build/RhodesSRC_build.files +1 -0
- data/platform/android/build/android.rake +2 -2
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +1 -0
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +18 -6
- data/platform/bb/build/bb.rake +1 -1
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +5 -4
- data/platform/iphone/Classes/SimpleMainView.m +1 -1
- data/platform/iphone/Info.plist +1 -1
- data/platform/shared/common/RhodesApp.cpp +9 -3
- data/platform/shared/curl/lib/rhossl.c +5 -2
- data/platform/shared/db/DBAdapter.cpp +9 -0
- data/platform/shared/net/CURLNetRequest.cpp +8 -3
- data/platform/shared/net/iphone/sslimpl.cpp +3 -2
- data/platform/shared/net/ssl.cpp +8 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +10 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +3 -4
- data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
- data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
- data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
- data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
- data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
- data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
- data/platform/win32/RhoSimulator/libeay32.dll +0 -0
- data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
- data/platform/wm/build/wm.rake +27 -3
- data/platform/wm/rhodes/Rhodes.cpp +4 -0
- data/platform/wm/rhodes/emulator/MainWindowCallback.h +1 -0
- data/platform/wm/rhodes/emulator/MainWindowProxy.cpp +3 -1
- data/platform/wm/rhodes/emulator/MainWindowQt.cpp +23 -12
- data/platform/wm/rhodes/emulator/MainWindowQt.h +5 -1
- data/platform/wm/rhodes/emulator/QtMainWindow.cpp +39 -6
- data/platform/wm/rhodes/emulator/QtMainWindow.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +5 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.Libraries.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.dll +0 -0
- data/platform/wp7/IronRuby/bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.Core.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.dll +0 -0
- data/platform/wp7/RhoAppRunner/Program.cs +2 -2
- data/platform/wp7/RhoRubyLib/RhoRuby.cs +8 -0
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +29 -7
- data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +5 -2
- data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +12 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +2 -0
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +1 -1
- data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +52 -7
- data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +85 -18
- data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +38 -3
- data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +27 -2
- data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +111 -15
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +330 -55
- data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +61 -4
- data/platform/wp7/build/wp.rake +89 -72
- data/platform/wp7/rhodes/App.xaml.cs +1 -1
- data/rakefile.rb +9 -2
- data/rhodes.gemspec +1 -3
- data/spec/phone_spec/app/spec/asynchttp_spec.rb +7 -9
- data/spec/phone_spec/app/spec/uri_spec.rb +75 -0
- data/spec/phone_spec/app/spec_runner.rb +4 -0
- metadata +21 -15
- data/Manifest.txt +0 -6403
- data/platform/win32/RhoSimulator/codecs/qcncodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qjpcodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qkrcodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qtwcodecs4.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
@@ -4,9 +4,11 @@ import android.app.Activity;
|
|
4
4
|
import android.content.BroadcastReceiver;
|
5
5
|
import android.content.Context;
|
6
6
|
import android.content.Intent;
|
7
|
+
import android.net.Uri;
|
7
8
|
import android.nfc.NdefMessage;
|
8
9
|
import android.nfc.NdefRecord;
|
9
10
|
import android.nfc.NfcAdapter;
|
11
|
+
import android.nfc.Tag;
|
10
12
|
import android.os.Build;
|
11
13
|
import android.os.Bundle;
|
12
14
|
import android.os.Parcelable;
|
@@ -22,30 +24,92 @@ public class NfcActivity extends Activity {
|
|
22
24
|
|
23
25
|
private static final String TAG = NfcActivity.class.getSimpleName();
|
24
26
|
|
27
|
+
private static Intent ourIntent = null;
|
28
|
+
|
25
29
|
@Override
|
26
30
|
protected void onCreate(Bundle savedInstanceState) {
|
27
31
|
super.onCreate(savedInstanceState);
|
28
32
|
Intent intent = getIntent();
|
29
33
|
String action = intent.getAction();
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
35
|
+
Utils.platformLog(TAG, " $$$$$$$$$ NfcActivity STARTED !!! Action = "+action);
|
36
|
+
|
37
|
+
|
38
|
+
if ( (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) ||
|
39
|
+
(NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) ||
|
40
|
+
(NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) ) {
|
41
|
+
|
42
|
+
RhodesActivity rhodes_activity = null;
|
43
|
+
// check RhodesActivity state
|
44
|
+
try {
|
45
|
+
rhodes_activity = RhodesActivity.safeGetInstance();
|
46
|
+
}
|
47
|
+
catch(NullPointerException e) {
|
48
|
+
|
49
|
+
}
|
50
|
+
boolean isForeground = false;
|
51
|
+
if (rhodes_activity != null) {
|
52
|
+
isForeground = rhodes_activity.isForegroundNow();
|
53
|
+
}
|
54
|
+
if (isForeground) {
|
55
|
+
Nfc.getInstance().onNewIntent(rhodes_activity, intent);
|
56
|
+
finish();
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
/*
|
60
|
+
ourIntent = intent;
|
61
|
+
Thread thread = new Thread() {
|
62
|
+
public void run() {
|
63
|
+
|
64
|
+
while (!isRhodesActivityOnForeground()) {
|
65
|
+
try {
|
66
|
+
sleep(100);
|
67
|
+
} catch (InterruptedException e) {
|
68
|
+
// TODO Auto-generated catch block
|
69
|
+
e.printStackTrace();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
Nfc.getInstance().onNewIntent(RhodesActivity.safeGetInstance(), ourIntent);
|
74
|
+
//finish();
|
75
|
+
//this.stop();
|
76
|
+
}
|
77
|
+
};
|
78
|
+
thread.start();
|
79
|
+
*/
|
80
|
+
Nfc.setApplicationStartupIntent(intent);
|
81
|
+
|
82
|
+
Intent run_intent = new Intent();
|
83
|
+
run_intent.setClass(this, RhodesActivity.class);
|
84
|
+
startActivity(run_intent);
|
85
|
+
|
86
|
+
finish();
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
//finish();
|
97
|
+
}
|
98
|
+
|
99
|
+
public static boolean isRhodesActivityOnForeground() {
|
100
|
+
RhodesActivity rhodes_activity = null;
|
101
|
+
// check RhodesActivity state
|
102
|
+
try {
|
103
|
+
rhodes_activity = RhodesActivity.safeGetInstance();
|
104
|
+
}
|
105
|
+
catch(NullPointerException e) {
|
106
|
+
|
107
|
+
}
|
108
|
+
boolean isForeground = false;
|
109
|
+
if (rhodes_activity != null) {
|
110
|
+
isForeground = rhodes_activity.isForegroundNow();
|
111
|
+
}
|
112
|
+
return isForeground;
|
49
113
|
}
|
50
114
|
|
51
115
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
package com.rhomobile.nfc;
|
2
2
|
|
3
|
+
import java.util.ArrayList;
|
4
|
+
import java.util.Iterator;
|
5
|
+
|
6
|
+
import android.nfc.FormatException;
|
3
7
|
import android.nfc.NdefMessage;
|
4
8
|
import android.nfc.NdefRecord;
|
5
9
|
import com.rhomobile.rhodes.Utils;
|
@@ -9,7 +13,27 @@ public class NfcMessage {
|
|
9
13
|
private NfcRecord[] mRecords = null;
|
10
14
|
private byte[] mByteArray = null;
|
11
15
|
|
16
|
+
private ArrayList<NfcRecord> mConstructRecords = null;
|
17
|
+
|
18
|
+
public NfcMessage(byte[] array) {
|
19
|
+
NdefMessage r = null;
|
20
|
+
try {
|
21
|
+
r = new NdefMessage(array);
|
22
|
+
} catch (FormatException e) {
|
23
|
+
Nfc.loge("Exception during make NdefMessage from byte array !");
|
24
|
+
e.printStackTrace();
|
25
|
+
}
|
26
|
+
initFromNdefMessage(r);
|
27
|
+
}
|
28
|
+
|
12
29
|
public NfcMessage(NdefMessage msg) {
|
30
|
+
initFromNdefMessage(msg);
|
31
|
+
}
|
32
|
+
|
33
|
+
public NfcMessage() {
|
34
|
+
}
|
35
|
+
|
36
|
+
private void initFromNdefMessage(NdefMessage msg) {
|
13
37
|
mByteArray = msg.toByteArray();
|
14
38
|
NdefRecord[] records = msg.getRecords();
|
15
39
|
mRecords = new NfcRecord[records.length];
|
@@ -19,6 +43,47 @@ public class NfcMessage {
|
|
19
43
|
}
|
20
44
|
}
|
21
45
|
|
46
|
+
public void addConstructRecord(NfcRecord record) {
|
47
|
+
if (mConstructRecords == null) {
|
48
|
+
mConstructRecords = new ArrayList<NfcRecord>();
|
49
|
+
}
|
50
|
+
mConstructRecords.add(record);
|
51
|
+
}
|
52
|
+
|
53
|
+
public void initFromConstructRecordList () {
|
54
|
+
if (mConstructRecords == null) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
ArrayList<NdefRecord> records = new ArrayList<NdefRecord>();
|
58
|
+
Iterator<NfcRecord> it = mConstructRecords.iterator();
|
59
|
+
while (it.hasNext()) {
|
60
|
+
NfcRecord nfcRec = it.next();
|
61
|
+
NdefRecord ndefRec = nfcRec.makeNdefRecord();
|
62
|
+
if (ndefRec != null) {
|
63
|
+
records.add(ndefRec);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
int i;
|
67
|
+
NdefRecord[] records_array = new NdefRecord[records.size()];
|
68
|
+
for (i = 0; i < records.size(); i++) {
|
69
|
+
records_array[i] = records.get(i);
|
70
|
+
}
|
71
|
+
NdefMessage m = new NdefMessage(records_array);
|
72
|
+
initFromNdefMessage(m);
|
73
|
+
mConstructRecords = null;
|
74
|
+
}
|
75
|
+
|
76
|
+
public NdefMessage makeNdefMessage() {
|
77
|
+
NdefMessage r = null;
|
78
|
+
try {
|
79
|
+
r = new NdefMessage(getByteArray());
|
80
|
+
} catch (FormatException e) {
|
81
|
+
Nfc.loge("Exception during make NdefMessage from byte array !");
|
82
|
+
e.printStackTrace();
|
83
|
+
}
|
84
|
+
return r;
|
85
|
+
}
|
86
|
+
|
22
87
|
public int getItemCount() {
|
23
88
|
return mRecords.length;
|
24
89
|
}
|
@@ -22,58 +22,122 @@ public class NfcRecord {
|
|
22
22
|
private NfcMessage mSubrecords = null;
|
23
23
|
|
24
24
|
|
25
|
+
public NfcRecord(byte[] array) {
|
26
|
+
NdefRecord r = null;
|
27
|
+
try {
|
28
|
+
r = new NdefRecord(array);
|
29
|
+
} catch (FormatException e) {
|
30
|
+
Nfc.loge("Exception during make NdefRecord from byte array !");
|
31
|
+
e.printStackTrace();
|
32
|
+
}
|
33
|
+
initFromNdefRecord(r);
|
34
|
+
}
|
25
35
|
|
26
36
|
public NfcRecord(NdefRecord rec) {
|
37
|
+
initFromNdefRecord(rec);
|
38
|
+
}
|
39
|
+
|
40
|
+
public NfcRecord(short tnf, byte[] type, byte[] id, byte[] payload) {
|
41
|
+
NdefRecord r = null;
|
42
|
+
r = new NdefRecord(tnf, type, id, payload);
|
43
|
+
initFromNdefRecord(r);
|
44
|
+
}
|
45
|
+
|
46
|
+
public void initFromNdefRecord(NdefRecord rec) {
|
27
47
|
|
48
|
+
if (rec == null) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
|
28
52
|
mId = rec.getId();
|
53
|
+
|
54
|
+
/*
|
55
|
+
if (mId != null) {
|
56
|
+
Utils.platformLog("NfcRecord", " ID = "+mId.toString());
|
57
|
+
|
58
|
+
StringBuffer s = new StringBuffer();
|
59
|
+
s.append(" ID is : ");
|
60
|
+
int i;
|
61
|
+
for (i = 0; i < mId.length; i++) {
|
62
|
+
s.append(mId[i]);
|
63
|
+
s.append(":");
|
64
|
+
}
|
65
|
+
Utils.platformLog("NfcRecord", s.toString());
|
66
|
+
|
67
|
+
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
Utils.platformLog("NfcRecord", " ID is NULL !!!");
|
71
|
+
}
|
72
|
+
*/
|
73
|
+
|
29
74
|
mPayload = rec.getPayload();
|
30
75
|
mTnf = rec.getTnf();
|
31
76
|
mType = rec.getType();
|
32
77
|
mByteArray = rec.toByteArray();
|
33
78
|
mPayloadString = "";
|
34
79
|
|
35
|
-
|
36
|
-
|
80
|
+
mPayloadString = makePayloadString((short)mTnf, mType, mPayload, this);
|
81
|
+
}
|
82
|
+
|
83
|
+
public static String makePayloadString(short tnf, byte[] type, byte[] payload, NfcRecord record) {
|
84
|
+
String payload_string = "";
|
85
|
+
try {
|
37
86
|
// detect type for prepare string from payload
|
38
|
-
if (
|
39
|
-
|
87
|
+
if (tnf == NdefRecord.TNF_ABSOLUTE_URI) {
|
88
|
+
payload_string = new String(payload, Charset.forName("UTF-8"));
|
40
89
|
}
|
41
|
-
else if (
|
42
|
-
if (Arrays.equals(
|
43
|
-
String prefix = getUriPrefixByNfcCode(
|
44
|
-
String uri = new String(Arrays.copyOfRange(
|
45
|
-
|
90
|
+
else if (tnf == NdefRecord.TNF_WELL_KNOWN) {
|
91
|
+
if (Arrays.equals(type, NdefRecord.RTD_URI)) {
|
92
|
+
String prefix = getUriPrefixByNfcCode(payload[0]);
|
93
|
+
String uri = new String(Arrays.copyOfRange(payload, 1, payload.length), Charset.forName("UTF-8"));
|
94
|
+
payload_string = prefix + uri;
|
46
95
|
}
|
47
|
-
else if (Arrays.equals(
|
48
|
-
String textEncoding = ((
|
49
|
-
int languageCodeLength =
|
50
|
-
String languageCode = new String(
|
51
|
-
String text = new String(
|
52
|
-
|
96
|
+
else if (Arrays.equals(type, NdefRecord.RTD_TEXT)) {
|
97
|
+
String textEncoding = ((payload[0] & 0200) == 0) ? "UTF-8" : "UTF-16";
|
98
|
+
int languageCodeLength = payload[0] & 0077;
|
99
|
+
String languageCode = new String(payload, 1, languageCodeLength, "US-ASCII");
|
100
|
+
String text = new String(payload, languageCodeLength + 1, payload.length - languageCodeLength - 1, textEncoding);
|
101
|
+
payload_string = text;
|
53
102
|
}
|
54
|
-
else if (Arrays.equals(
|
103
|
+
else if (Arrays.equals(type, NdefRecord.RTD_SMART_POSTER)) {
|
55
104
|
try {
|
56
|
-
NdefMessage subRecords = new NdefMessage(
|
57
|
-
|
105
|
+
NdefMessage subRecords = new NdefMessage(payload);
|
106
|
+
if (record != null) {
|
107
|
+
record.mSubrecords = new NfcMessage(subRecords);
|
108
|
+
}
|
58
109
|
} catch (FormatException e) {
|
59
110
|
//throw new IllegalArgumentException(e);
|
60
|
-
|
111
|
+
Nfc.loge("constructor of NfcRecord: Invalid record with RTD_SMART_POSTER type !");
|
61
112
|
}
|
62
113
|
}
|
63
114
|
else {
|
64
|
-
|
115
|
+
payload_string = new String(payload, Charset.forName("UTF-8"));
|
65
116
|
}
|
66
117
|
}
|
67
118
|
else {
|
68
|
-
|
119
|
+
payload_string = new String(payload, Charset.forName("UTF-8"));
|
69
120
|
}
|
70
121
|
} catch (UnsupportedEncodingException e) {
|
71
122
|
// should never happen unless we get a malformed tag.
|
72
123
|
//throw new IllegalArgumentException(e);
|
73
|
-
|
124
|
+
Nfc.loge("construct string from payload: catch UnsupportedEncodingException - tag maybe broken !");
|
74
125
|
}
|
126
|
+
|
127
|
+
return payload_string;
|
75
128
|
}
|
76
|
-
|
129
|
+
|
130
|
+
public NdefRecord makeNdefRecord() {
|
131
|
+
NdefRecord r = null;
|
132
|
+
try {
|
133
|
+
r = new NdefRecord(getByteArray());
|
134
|
+
} catch (FormatException e) {
|
135
|
+
Nfc.loge("Exception during make NdefRecord from byte array !");
|
136
|
+
e.printStackTrace();
|
137
|
+
}
|
138
|
+
return r;
|
139
|
+
}
|
140
|
+
|
77
141
|
public byte[] getId() {
|
78
142
|
return mId;
|
79
143
|
}
|
@@ -103,7 +167,7 @@ public class NfcRecord {
|
|
103
167
|
}
|
104
168
|
|
105
169
|
|
106
|
-
private String getUriPrefixByNfcCode(byte code) {
|
170
|
+
private static String getUriPrefixByNfcCode(byte code) {
|
107
171
|
switch(code) {
|
108
172
|
case 0x00: return "";
|
109
173
|
case 0x01: return "http://www.";
|
@@ -25,6 +25,8 @@ public class NfcTechActivity extends Activity {
|
|
25
25
|
|
26
26
|
@Override
|
27
27
|
protected void onCreate(Bundle savedInstanceState) {
|
28
|
+
|
29
|
+
/* NOT USED NOW !
|
28
30
|
super.onCreate(savedInstanceState);
|
29
31
|
Intent intent = getIntent();
|
30
32
|
String action = intent.getAction();
|
@@ -36,6 +38,7 @@ public class NfcTechActivity extends Activity {
|
|
36
38
|
}
|
37
39
|
}
|
38
40
|
finish();
|
41
|
+
*/
|
39
42
|
}
|
40
43
|
|
41
44
|
|
@@ -42,15 +42,160 @@ extern void rho_nfc_tech_MifareClassic_write_block(int index, VALUE block);
|
|
42
42
|
extern VALUE rho_nfc_tech_MifareClassic_read_block(int index);
|
43
43
|
#define tech_MifareClassic_read_block rho_nfc_tech_MifareClassic_read_block
|
44
44
|
|
45
|
-
extern int
|
46
|
-
#define
|
45
|
+
extern int rho_nfc_tech_MifareClassic_get_block_count();
|
46
|
+
#define tech_MifareClassic_get_block_count rho_nfc_tech_MifareClassic_get_block_count
|
47
47
|
|
48
|
+
extern int rho_nfc_tech_MifareClassic_get_sector_count();
|
49
|
+
#define tech_MifareClassic_get_sector_count rho_nfc_tech_MifareClassic_get_sector_count
|
50
|
+
|
51
|
+
extern int rho_nfc_tech_MifareClassic_get_blocks_in_sector_count(int index);
|
52
|
+
#define tech_MifareClassic_get_blocks_in_sector_count rho_nfc_tech_MifareClassic_get_blocks_in_sector_count
|
53
|
+
|
54
|
+
extern int rho_nfc_tech_MifareClassic_sector_to_block(int index);
|
55
|
+
#define tech_MifareClassic_sector_to_block rho_nfc_tech_MifareClassic_sector_to_block
|
56
|
+
|
57
|
+
extern int rho_nfc_tech_MifareClassic_authenticate_sector_with_key_A(int index, VALUE key);
|
58
|
+
#define tech_MifareClassic_authenticate_sector_with_key_A rho_nfc_tech_MifareClassic_authenticate_sector_with_key_A
|
59
|
+
|
60
|
+
extern int rho_nfc_tech_MifareClassic_authenticate_sector_with_key_B(int index, VALUE key);
|
61
|
+
#define tech_MifareClassic_authenticate_sector_with_key_B rho_nfc_tech_MifareClassic_authenticate_sector_with_key_B
|
62
|
+
|
63
|
+
extern int rho_nfc_tech_MifareClassic_get_type();
|
64
|
+
#define tech_MifareClassic_get_type rho_nfc_tech_MifareClassic_get_type
|
65
|
+
|
66
|
+
extern VALUE rho_nfc_tech_MifareClassic_transceive(VALUE data);
|
67
|
+
#define tech_MifareClassic_transceive rho_nfc_tech_MifareClassic_transceive
|
68
|
+
|
69
|
+
extern VALUE rho_nfc_tag_get_id();
|
70
|
+
#define tag_get_id rho_nfc_tag_get_id
|
71
|
+
|
48
72
|
extern void rho_nfc_tech_MifareUltralight_write_page(int index, VALUE block);
|
49
73
|
#define tech_MifareUltralight_write_page rho_nfc_tech_MifareUltralight_write_page
|
50
74
|
|
51
75
|
extern VALUE rho_nfc_tech_MifareUltralight_read_pages(int index);
|
52
76
|
#define tech_MifareUltralight_read_pages rho_nfc_tech_MifareUltralight_read_pages
|
53
77
|
|
78
|
+
extern int rho_nfc_tech_MifareUltralight_get_type();
|
79
|
+
#define tech_MifareUltralight_get_type rho_nfc_tech_MifareUltralight_get_type
|
80
|
+
|
81
|
+
extern VALUE rho_nfc_tech_MifareUltralight_transceive(VALUE data);
|
82
|
+
#define tech_MifareUltralight_transceive rho_nfc_tech_MifareUltralight_transceive
|
83
|
+
|
84
|
+
extern int rho_nfc_tech_Ndef_get_max_size();
|
85
|
+
#define tech_Ndef_get_max_size rho_nfc_tech_Ndef_get_max_size
|
86
|
+
|
87
|
+
extern VALUE rho_nfc_tech_Ndef_get_type();
|
88
|
+
#define tech_Ndef_get_type rho_nfc_tech_Ndef_get_type
|
89
|
+
|
90
|
+
extern int rho_nfc_tech_Ndef_is_writable();
|
91
|
+
#define tech_Ndef_is_writable rho_nfc_tech_Ndef_is_writable
|
92
|
+
|
93
|
+
extern int rho_nfc_tech_Ndef_can_make_read_only();
|
94
|
+
#define tech_Ndef_can_make_read_only rho_nfc_tech_Ndef_can_make_read_only
|
95
|
+
|
96
|
+
extern int rho_nfc_tech_Ndef_make_read_only();
|
97
|
+
#define tech_Ndef_make_read_only rho_nfc_tech_Ndef_make_read_only
|
98
|
+
|
99
|
+
extern void rho_nfc_tech_Ndef_write_Nde_message(VALUE message_in_byte_array);
|
100
|
+
#define tech_Ndef_write_Nde_message rho_nfc_tech_Ndef_write_Nde_message
|
101
|
+
|
102
|
+
extern VALUE rho_nfc_tech_Ndef_read_Nde_message();
|
103
|
+
#define tech_Ndef_read_Nde_message rho_nfc_tech_Ndef_read_Nde_message
|
104
|
+
|
105
|
+
extern VALUE rho_nfc_tech_NfcA_get_Atqa();
|
106
|
+
#define tech_NfcA_get_Atqa rho_nfc_tech_NfcA_get_Atqa
|
107
|
+
|
108
|
+
extern int rho_nfc_tech_NfcA_get_Sak();
|
109
|
+
#define tech_NfcA_get_Sak rho_nfc_tech_NfcA_get_Sak
|
110
|
+
|
111
|
+
extern VALUE rho_nfc_tech_NfcA_transceive(VALUE data);
|
112
|
+
#define tech_NfcA_transceive rho_nfc_tech_NfcA_transceive
|
113
|
+
|
114
|
+
extern VALUE rho_nfc_convert_byte_array_to_NdeRecord_hash(VALUE array);
|
115
|
+
#define convert_byte_array_to_NdeRecord_hash rho_nfc_convert_byte_array_to_NdeRecord_hash
|
116
|
+
|
117
|
+
extern VALUE rho_nfc_convert_NdeRecord_hash_to_byte_array(VALUE array);
|
118
|
+
#define convert_NdeRecord_hash_to_byte_array rho_nfc_convert_NdeRecord_hash_to_byte_array
|
119
|
+
|
120
|
+
extern VALUE rho_nfc_convert_NdeMessage_byte_array_to_NdeRecords_array(VALUE array);
|
121
|
+
#define convert_NdeMessage_byte_array_to_NdeRecords_array rho_nfc_convert_NdeMessage_byte_array_to_NdeRecords_array
|
122
|
+
|
123
|
+
extern VALUE rho_nfc_convert_NdeRecords_array_to_NdeMessage_byte_array(VALUE array);
|
124
|
+
#define convert_NdeRecords_array_to_NdeMessage_byte_array rho_nfc_convert_NdeRecords_array_to_NdeMessage_byte_array
|
125
|
+
|
126
|
+
extern VALUE rho_nfc_make_string_from_payload(VALUE payload, int tnf, VALUE type);
|
127
|
+
#define make_string_from_payload rho_nfc_make_string_from_payload
|
128
|
+
|
129
|
+
extern VALUE rho_nfc_make_payload_with_absolute_uri(const char* str);
|
130
|
+
#define make_payload_with_absolute_uri rho_nfc_make_payload_with_absolute_uri
|
131
|
+
|
132
|
+
extern VALUE rho_nfc_make_payload_with_well_known_text(const char* language, const char* str);
|
133
|
+
#define make_payload_with_well_known_text rho_nfc_make_payload_with_well_known_text
|
134
|
+
|
135
|
+
extern VALUE rho_nfc_make_payload_with_well_known_uri(int prefix, const char* str);
|
136
|
+
#define make_payload_with_well_known_uri rho_nfc_make_payload_with_well_known_uri
|
137
|
+
|
138
|
+
extern void rho_nfc_p2p_enable_foreground_nde_push(VALUE nde_message_byte_array);
|
139
|
+
#define p2p_enable_foreground_nde_push rho_nfc_p2p_enable_foreground_nde_push
|
140
|
+
|
141
|
+
extern void rho_nfc_p2p_disable_foreground_nde_push();
|
142
|
+
#define p2p_disable_foreground_nde_push rho_nfc_p2p_disable_foreground_nde_push
|
143
|
+
|
144
|
+
extern VALUE rho_nfc_tech_IsoDep_get_hi_layer_responce();
|
145
|
+
#define tech_IsoDep_get_hi_layer_responce rho_nfc_tech_IsoDep_get_hi_layer_responce
|
146
|
+
|
147
|
+
extern VALUE rho_nfc_tech_IsoDep_get_historical_bytes();
|
148
|
+
#define tech_IsoDep_get_historical_bytes rho_nfc_tech_IsoDep_get_historical_bytes
|
149
|
+
|
150
|
+
extern void rho_nfc_tech_IsoDep_set_timeout(int timeout);
|
151
|
+
#define tech_IsoDep_set_timeout rho_nfc_tech_IsoDep_set_timeout
|
152
|
+
|
153
|
+
extern VALUE rho_nfc_tech_IsoDep_transceive(VALUE data);
|
154
|
+
#define tech_IsoDep_transceive rho_nfc_tech_IsoDep_transceive
|
155
|
+
|
156
|
+
extern void rho_nfc_tech_NdefFormatable_format(VALUE ndef_message_byte_array);
|
157
|
+
#define tech_NdefFormatable_format rho_nfc_tech_NdefFormatable_format
|
158
|
+
|
159
|
+
extern void rho_nfc_tech_NdefFormatable_format_read_only(VALUE ndef_message_byte_array);
|
160
|
+
#define tech_NdefFormatable_format_read_only rho_nfc_tech_NdefFormatable_format_read_only
|
161
|
+
|
162
|
+
// return byte[]
|
163
|
+
extern VALUE rho_nfc_tech_NfcB_get_application_data();
|
164
|
+
#define tech_NfcB_get_application_data rho_nfc_tech_NfcB_get_application_data
|
165
|
+
|
166
|
+
// return byte[]
|
167
|
+
extern VALUE rho_nfc_tech_NfcB_get_protocol_info();
|
168
|
+
#define tech_NfcB_get_protocol_info rho_nfc_tech_NfcB_get_protocol_info
|
169
|
+
|
170
|
+
// byte[] -> byte[]
|
171
|
+
extern VALUE rho_nfc_tech_NfcB_transceive(VALUE data);
|
172
|
+
#define tech_NfcB_transceive rho_nfc_tech_NfcB_transceive
|
173
|
+
|
174
|
+
// return byte[]
|
175
|
+
extern VALUE rho_nfc_tech_NfcF_get_manufacturer();
|
176
|
+
#define tech_NfcF_get_manufacturer rho_nfc_tech_NfcF_get_manufacturer
|
177
|
+
|
178
|
+
// return byte[]
|
179
|
+
extern VALUE rho_nfc_tech_NfcF_get_system_code();
|
180
|
+
#define tech_NfcF_get_system_code rho_nfc_tech_NfcF_get_system_code
|
181
|
+
|
182
|
+
// byte[] -> byte[]
|
183
|
+
extern VALUE rho_nfc_tech_NfcF_transceive(VALUE data);
|
184
|
+
#define tech_NfcF_transceive rho_nfc_tech_NfcF_transceive
|
185
|
+
|
186
|
+
extern int rho_nfc_tech_NfcV_get_dsf_id();
|
187
|
+
#define tech_NfcV_get_dsf_id rho_nfc_tech_NfcV_get_dsf_id
|
188
|
+
|
189
|
+
extern int rho_nfc_tech_NfcV_get_responce_flags();
|
190
|
+
#define tech_NfcV_get_responce_flags rho_nfc_tech_NfcV_get_responce_flags
|
191
|
+
|
192
|
+
// byte[] -> byte[]
|
193
|
+
extern VALUE rho_nfc_tech_NfcV_transceive(VALUE data);
|
194
|
+
#define tech_NfcV_transceive rho_nfc_tech_NfcV_transceive
|
195
|
+
|
196
|
+
extern void rho_nfc_perform_open_application_event();
|
197
|
+
#define perform_open_application_event rho_nfc_perform_open_application_event
|
198
|
+
|
54
199
|
%}
|
55
200
|
|
56
201
|
extern void set_callback(const char* callback_url);
|
@@ -66,7 +211,63 @@ extern int tech_is_connected(const char* name);
|
|
66
211
|
extern int tech_MifareClassic_get_size();
|
67
212
|
extern void tech_MifareClassic_write_block(int index, VALUE block);
|
68
213
|
extern VALUE tech_MifareClassic_read_block(int index);
|
69
|
-
extern int
|
214
|
+
extern int tech_MifareClassic_get_block_count();
|
215
|
+
extern int tech_MifareClassic_get_sector_count();
|
216
|
+
extern int tech_MifareClassic_get_blocks_in_sector_count(int index);
|
217
|
+
extern int tech_MifareClassic_sector_to_block(int index);
|
218
|
+
extern int tech_MifareClassic_authenticate_sector_with_key_A(int index, VALUE key);
|
219
|
+
extern int tech_MifareClassic_authenticate_sector_with_key_B(int index, VALUE key);
|
220
|
+
extern int tech_MifareClassic_get_type();
|
221
|
+
extern VALUE tag_get_id();
|
222
|
+
extern VALUE tech_MifareClassic_transceive(VALUE data);
|
70
223
|
extern void tech_MifareUltralight_write_page(int index, VALUE block);
|
71
224
|
extern VALUE tech_MifareUltralight_read_pages(int index);
|
225
|
+
extern int tech_MifareUltralight_get_type();
|
226
|
+
extern VALUE tech_MifareUltralight_transceive(VALUE data);
|
227
|
+
extern int tech_Ndef_get_max_size();
|
228
|
+
extern VALUE tech_Ndef_get_type();
|
229
|
+
extern int tech_Ndef_is_writable();
|
230
|
+
extern int tech_Ndef_can_make_read_only();
|
231
|
+
extern int tech_Ndef_make_read_only();
|
232
|
+
extern void tech_Ndef_write_Nde_message(VALUE message_in_byte_array);
|
233
|
+
extern VALUE tech_Ndef_read_Nde_message();
|
234
|
+
extern VALUE tech_NfcA_get_Atqa();
|
235
|
+
extern int tech_NfcA_get_Sak();
|
236
|
+
extern VALUE tech_NfcA_transceive(VALUE data);
|
237
|
+
extern VALUE convert_byte_array_to_NdeRecord_hash(VALUE array);
|
238
|
+
extern VALUE convert_NdeRecord_hash_to_byte_array(VALUE array);
|
239
|
+
extern VALUE convert_NdeMessage_byte_array_to_NdeRecords_array(VALUE array);
|
240
|
+
extern VALUE convert_NdeRecords_array_to_NdeMessage_byte_array(VALUE array);
|
241
|
+
extern VALUE make_string_from_payload(VALUE payload, int tnf, VALUE type);
|
242
|
+
extern VALUE make_payload_with_absolute_uri(const char* str);
|
243
|
+
extern VALUE make_payload_with_well_known_text(const char* language, const char* str);
|
244
|
+
extern VALUE make_payload_with_well_known_uri(int prefix, const char* str);
|
245
|
+
extern void p2p_enable_foreground_nde_push(VALUE nde_message_byte_array);
|
246
|
+
extern void p2p_disable_foreground_nde_push();
|
247
|
+
extern VALUE tech_IsoDep_get_hi_layer_responce();
|
248
|
+
extern VALUE tech_IsoDep_get_historical_bytes();
|
249
|
+
extern void tech_IsoDep_set_timeout(int timeout);
|
250
|
+
extern VALUE tech_IsoDep_transceive(VALUE data);
|
251
|
+
extern void tech_NdefFormatable_format(VALUE ndef_message_byte_array);
|
252
|
+
extern void tech_NdefFormatable_format_read_only(VALUE ndef_message_byte_array);
|
253
|
+
extern VALUE tech_NfcB_get_application_data();
|
254
|
+
extern VALUE tech_NfcB_get_protocol_info();
|
255
|
+
extern VALUE tech_NfcB_transceive(VALUE data);
|
256
|
+
extern VALUE tech_NfcF_get_manufacturer();
|
257
|
+
extern VALUE tech_NfcF_get_system_code();
|
258
|
+
extern VALUE tech_NfcF_transceive(VALUE data);
|
259
|
+
extern int tech_NfcV_get_dsf_id();
|
260
|
+
extern int tech_NfcV_get_responce_flags();
|
261
|
+
extern VALUE tech_NfcV_transceive(VALUE data);
|
262
|
+
extern void perform_open_application_event();
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
72
273
|
|