First attempt to reach xmlrpc server

This commit is contained in:
Sylvain Berfini 2015-04-21 14:56:11 +02:00
parent 21d92c4c01
commit 940b67221b
3 changed files with 46 additions and 7 deletions

View file

@ -31,3 +31,6 @@ dtmf_player_amp=0.1
max_calls=10 max_calls=10
log_collection_upload_server_url=https://www.linphone.org:444/lft.php log_collection_upload_server_url=https://www.linphone.org:444/lft.php
user_certificates_path=/data/data/org.linphone/files user_certificates_path=/data/data/org.linphone/files
[in-app-purchase]
server_url=https://www.linphone.org/wizard2.php

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import java.util.ArrayList; import java.util.ArrayList;
import org.linphone.R; import org.linphone.R;
import org.linphone.mediastream.Log;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@ -31,6 +32,7 @@ import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
/** /**
* @author Sylvain Berfini * @author Sylvain Berfini
@ -58,6 +60,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
@Override @Override
public void onServiceAvailableForQueries() { public void onServiceAvailableForQueries() {
inAppPurchaseHelper.getAvailableItemsForPurchaseAsync(); inAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
inAppPurchaseHelper.getPurchasedItemsAsync();
} }
@Override @Override
@ -76,7 +79,9 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
@Override @Override
public void onPurchasedItemsQueryFinished(ArrayList<Purchasable> items) { public void onPurchasedItemsQueryFinished(ArrayList<Purchasable> items) {
for (Purchasable item : items) {
Log.d("[In-app] Item " + item.getTitle() + " is already bought");
}
} }
@Override @Override

View file

@ -51,7 +51,7 @@ import de.timroes.axmlrpc.XMLRPCServerException;
*/ */
public class InAppPurchaseHelper { public class InAppPurchaseHelper {
public static final int API_VERSION = 3; public static final int API_VERSION = 3;
public static final String TEST_ITEM = "android.test.purchased"; public static final String TEST_ITEM = "test_account_subscription";
public static final int ACTIVITY_RESULT_CODE_PURCHASE_ITEM = 11089; public static final int ACTIVITY_RESULT_CODE_PURCHASE_ITEM = 11089;
public static final String SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST"; public static final String SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST";
@ -65,6 +65,15 @@ public class InAppPurchaseHelper {
public static final String ITEM_TYPE_SUBS = "subs"; public static final String ITEM_TYPE_SUBS = "subs";
public static final int RESPONSE_RESULT_OK = 0; public static final int RESPONSE_RESULT_OK = 0;
public static final int RESULT_USER_CANCELED = 1;
public static final int RESULT_SERVICE_UNAVAILABLE = 2;
public static final int RESULT_BILLING_UNAVAILABLE = 3;
public static final int RESULT_ITEM_UNAVAILABLE = 4;
public static final int RESULT_DEVELOPER_ERROR = 5;
public static final int RESULT_ERROR = 6;
public static final int RESULT_ITEM_ALREADY_OWNED = 7;
public static final int RESULT_ITEM_NOT_OWNED = 8;
public static final String RESPONSE_CODE = "RESPONSE_CODE"; public static final String RESPONSE_CODE = "RESPONSE_CODE";
public static final String RESPONSE_BUY_INTENT = "BUY_INTENT"; public static final String RESPONSE_BUY_INTENT = "BUY_INTENT";
public static final String RESPONSE_INAPP_PURCHASE_DATA = "INAPP_PURCHASE_DATA"; public static final String RESPONSE_INAPP_PURCHASE_DATA = "INAPP_PURCHASE_DATA";
@ -88,6 +97,28 @@ public class InAppPurchaseHelper {
private ServiceConnection mServiceConn; private ServiceConnection mServiceConn;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private String responseCodeToErrorMessage(int responseCode) {
switch (responseCode) {
case RESULT_USER_CANCELED:
return "BILLING_RESPONSE_RESULT_USER_CANCELED";
case RESULT_SERVICE_UNAVAILABLE:
return "BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE";
case RESULT_BILLING_UNAVAILABLE:
return "BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE";
case RESULT_ITEM_UNAVAILABLE:
return "BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE";
case RESULT_DEVELOPER_ERROR:
return "BILLING_RESPONSE_RESULT_DEVELOPER_ERROR";
case RESULT_ERROR:
return "BILLING_RESPONSE_RESULT_ERROR";
case RESULT_ITEM_ALREADY_OWNED:
return "BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED";
case RESULT_ITEM_NOT_OWNED:
return "BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED";
}
return "UNKNOWN_RESPONSE_CODE";
}
public InAppPurchaseHelper(Activity context, InAppPurchaseListener listener) { public InAppPurchaseHelper(Activity context, InAppPurchaseListener listener) {
mContext = context; mContext = context;
mListener = listener; mListener = listener;
@ -165,7 +196,7 @@ public class InAppPurchaseHelper {
} }
} }
} else { } else {
Log.e("[In-app purchase] Error: responde code is not ok: " + response); Log.e("[In-app purchase] Error: responde code is not ok: " + responseCodeToErrorMessage(response));
} }
} }
@ -222,7 +253,7 @@ public class InAppPurchaseHelper {
}, purchaseData, signature); }, purchaseData, signature);
} }
} else { } else {
Log.e("[In-app purchase] Error: responde code is not ok: " + response); Log.e("[In-app purchase] Error: responde code is not ok: " + responseCodeToErrorMessage(response));
} }
} }
} while (continuationToken != null); } while (continuationToken != null);
@ -279,7 +310,7 @@ public class InAppPurchaseHelper {
} }
}, purchaseData, signature); }, purchaseData, signature);
} else { } else {
Log.e("[In-app purchase] Error: resultCode is " + resultCode + " and responseCode is " + responseCode); Log.e("[In-app purchase] Error: resultCode is " + resultCode + " and responseCode is " + responseCodeToErrorMessage(responseCode));
} }
} }
} }
@ -321,7 +352,7 @@ public class InAppPurchaseHelper {
public void onError(long id, XMLRPCException error) { public void onError(long id, XMLRPCException error) {
Log.e(error); Log.e(error);
} }
}, "create_account_from_in_app_purchase", "android", purchasedData, signature); }, "create_account_from_in_app_purchase", "sylvain@sip.linphone.org", "toto", purchasedData, signature, "google");
} }
} }