[Q][JS] Parse Cloud Code problem. - Web App Development

Hello.
I'm working on a project where I need to store some information from the Windows Phone store in my Parse database, but since I'm new to both Parse and JavaScript (only supported language for Cloud Code) I need some help.
There seem to be something wrong with a property, but more than that I can't get, not which row or anything.
My code at the moment is this:
Code:
Parse.Cloud.job("getWP8Apps", function(request, response) {
Parse.Cloud.useMasterKey();
var query = new Parse.Query("developer");
query.each(function(results) {
Parse.Cloud.httpRequest({
url: 'http://zunderstorehost.azurewebsites.net/api/WP8StoreAppList/Publisher/' + results.get("publisherName"),
success: function(httpResponse) {
var apps = httpResponse.data;
for(var app in apps) {
var application = Parse.Object.extend("application");
var newApp = new application();
newApp.save({
categories: app.categories,
guid: app.guid,
haslivetile: app.haslivetile,
icon: app.icon,
mame: app.name,
offers: app.offers,
publisher: app.publisher,
publisherid: app.publisherid,
rating: app.rating,
ratingCount: app.ratingcount,
releaseDate: app.releasedate,
version: app.version
}, {
success: function(newApp){ console.log(app.name + " saved!"); },
error: function(newApp, error) {console.error("Something failed: " + error.description); }});
}
},
error: function(error) {
console.error("Something failed: " + error.description);
}
});
});
});
The developer object that I'm fetching from the storage is a small collection of items containing some general information about the different developers included in this, amongst that information, their Windows Phone Store Publisher Name which is to be used to fetch a list of their published applications.
The application object is a json converted class through the Parse Class Import function (that function converts the Json to a valid table structure for data storage of the result).
So, anyone with some ideas on what could be the issue here?
Any help is highly appreciated!
NOTE: This code is to run in the cloud, not in the app. Thats why I posted this in the web section. If it fits better somewhere else, feel free to move it.

Related

[REQ]How to retrive the Storage Card name

Hi all,
Does anyone know how to retrive (identify) the system name of the Storage Card using .Net C.F. and Visual Basic language?
This is because often changig the WM version or the localization of the device, can also change the name of the Storage Card (with related "Path not found" error in the program).
Thanks for help
using C#.net
Code:
private static string GetStorageCardPath()
{
DirectoryInfo di = new DirectoryInfo(@"\");
FileSystemInfo[] fsi = di.GetFileSystemInfos();
foreach (FileSystemInfo fileSystemInfo in fsi)
{
if ((fileSystemInfo.Attributes & FileAttributes.Temporary) == FileAttributes.Temporary)
{
return fileSystemInfo.FullName;
}
}
return null;
}
and with convert csharp to vb in VB.net
Code:
Private Shared Function GetStorageCardPath() As String
Dim di As New DirectoryInfo("\")
Dim fsi As FileSystemInfo() = di.GetFileSystemInfos()
For Each fileSystemInfo As FileSystemInfo In fsi
If (fileSystemInfo.Attributes And FileAttributes.Temporary) = FileAttributes.Temporary Then
Return fileSystemInfo.FullName
End If
Next
Return Nothing
End Function
Thanks HeliosDev!

MFC support for native WP7 Dll (and Exe too)

Hello friends.
I am a lazy person with a lack of time. So, when I wanted to Phone Commander to add support for exporting registry keys to a file, I found an older, freely usable code (first I tried RegSaveKey coredll function, but I coud not elevate calling Process privilegies). PCMD will be the first "ondevice" WP7 application that allows you to export this (thanks Ultrashot we can also do it from a PC by Remote Tools). Unfortunately, the obtained code was using an MFC classes (CFile etc). Probably would not be a problem to rewrite it for another entry in the file, but I do not want change 3rd code. And MFC can be useful in the future too.
There were basically two options:
1. Use dynamic linking, because statically linking MFC to ATL is not allowed (conflicts of application instances). But then I had to get the correct library and try if they will run on WP7. In the future, I'll try.
2. Take all the MFC source code (included in WM DTK) and rewrite them to work statically in WP7, with prepared out CWinApp etc. It was a nasty job, but for some classes (especially CFile) is complete and functional to use. Next week there will publish libraries, source code and tutorial to use MFC classes in ATL native WP7 projects. EDIT: See 2nd post, this is probably better way then first one.
Meanwhile small code sample to export registers (ExportRegKey is 3rd function using CFile parameter):
Code:
BOOL ExportRegKey(HKEY hroot, const CString &root, const CString &key, CFile &out);
STDMETHODIMP CRegistryX::RegExportKeySimple(DWORD dwKey, LPCWSTR szSubKey, LPCWSTR szFileName)
{
TRACE(L"RegExportKeySimple(DWORD dwKey = %X, LPCWSTR szSubKey = %s, LPCWSTR szFileName = %s)", dwKey, szSubKey, szFileName);
try
{
HKEY hKey = (HKEY) dwKey;
LONG lRes = ERROR_SUCCESS;
CString root = L"";
switch (dwKey)
{
case HKEY_LOCAL_MACHINE:
{
root = _T("HKEY_LOCAL_MACHINE");
} break;
case HKEY_CURRENT_USER:
{
root = _T("HKEY_CURRENT_USER");
} break;
case HKEY_CLASSES_ROOT:
{
root = _T("HKEY_CLASSES_ROOT");
} break;
case HKEY_USERS:
{
root = _T("HKEY_USERS");
} break;
/*
case HKEY_CURRENT_CONFIG:
{
root = _T("HKEY_CURRENT_CONFIG");
} break;
*/
default:
{
root = _T("HKEY_UNKNOWN");
} break;
root = _T("");
}
CString key = szSubKey;
CFile out;
out.Open(szFileName, CFile::modeWrite | CFile::modeCreate );
lRes = ExportRegKey(hKey, root, key, out);
out.Close();
TRACE(L"RegExportKeySimple ExportRegKey lRes = %d)", lRes);
if (lRes == ERROR_SUCCESS)
{
return S_OK;
}
else
{
return ReturnError(L"RegSetDwordSimple RegSetValueEx", 0x80070000 | lRes);
}
}
catch (...)
{
return ReturnError(L"RegGetDwordSimple", GetLastError());
}
}
This is also Native TRACE example to see native messages in VP2010 managed Output window.
Full MFC using
I tried FULL MFC from VS2008 CE SDK using and this is possible.
1. Exe files - success with statical or dynamical MFC linking. Drawable components may have problems only.
2. Static linking to dll: If we can want use native dll with statically linked MFC to managed VS2010 dll or application, there are two ways:
- To change our usual COM interface to MFC standard. It may be possible, but I did not try it.
- To make ATL interstitial ATL dll with COM interface, which can call exported functions from MFC dll.
3. Dynamical MFC linking to ATL (COM) dll. I mean thi is the best way now.
For dynamical linking MFC dlls must be copied to device - to appplication directory or ideally to \Windows directory. Mostly:
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\msvcr90.dll
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\atl90.dll
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\msvcr90d.dll
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\MFC90UD.dll

prevent POST-request from caching

Hi,
when I try to make a jquery ajax "Typeost" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked. Here some code snippets to ilustrate my attempts:
This is my Ajax POST request:
Code:
$.ajaxSetup({
headers: {
"X-Requested-With" : "XMLHttpRequest",
"Content-Type" : "application/atom+xml",
"cache-control" : "no-cache",
"DataServiceVersion" : "2.0",
"X-CSRF-Token" : header_xcsrf_token,
},
cache: false,
});
$.ajax({
type: 'POST',
url: url + new Date().getTime(),
data : data,
beforeSend : function(xhr) {
// crypto call before authentication
var bytes = Crypto.charenc.Binary.stringToBytes(user + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
//build request header
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, status, xhr) {
alert("data sent");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown + " " + jqXHR.status + " " + jqXHR.responseText);
}
});
I've also tried to avoid the AppCache with following code in JAVA onCreate Method:
HTML:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
super.appView.getSettings().setAppCacheEnabled(false);
super.loadUrl(Config.getStartUrl());
CookieManager.getInstance().setAcceptCookie(true);
// Set by <content src="index.html" /> in config.xml
//super.loadUrl("file:///android_asset/www/index.html");
}
every time the Ajax Post request is made, it is directed to cache, and I don't know how to prevent it.
Cris Vilares said:
Hi,
when I try to make a jquery ajax "Typeost" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked.
Click to expand...
Click to collapse
You're probably getting a 404 because you're appending the timestamp onto the url without any seperator. Try this...
Code:
$.ajax({
type: 'POST',
url: url + (url.search("?") == -1 ? "?" : "&") + new Date().getTime(),
data : data,
beforeSend : function(xhr) {
// crypto call before authentication
var bytes = Crypto.charenc.Binary.stringToBytes(user + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
//build request header
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, status, xhr) {
alert("data sent");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown + " " + jqXHR.status + " " + jqXHR.responseText);
}
});
That will append either ?nnnnnnnn or &nnnnnnnn to the url, depending on whether it already has a ? in it.

[Help] Loading image to replace camera buffer

So I've created module to hijack an app's onPictureTaken callback method to manipulate the image-data that is returned from the Camera (android.hardware.Camera.PictureCallback).
I have succeeded to manipulate the image to return a Grayscale of it which was my first goal.
Now I want to replace the entire image with an image loaded from the filesystem which I'm unsuccessful in doing. I've tried different methods, paths etc. but haven't managed to do it. I've never been able to find the file which I want to load.
The full path of the image file I want to load is according to Solid Explorer
Code:
/storage/emulated/0/input.png
What code should I use to load the filesystem image into a Bitmap?
Do I need to take any extra Camera parameters into account that says stuff about the image?
Do I need take file permissions into account?
I'm running an OPO on Lollipop 5.0.2 / Cyanogen OS 12.0 / Xposed 67
This is the code I've used to create the Grayscale example:
Code:
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.os.Environment;
import java.io.ByteArrayOutputStream;
import java.io.File;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class CamHook implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (!lpparam.packageName.equals("somepackage.somewhere.app"))
return;
XposedBridge.log("CamHook: We're here!");
findAndHookMethod("somepackage.somewhere.app.NewPhotoFragment$3$1", lpparam.classLoader, "onPictureTaken", "byte[]", "android.hardware.Camera", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("CamHook: before picture taken");
XposedBridge.log("CamHook: byteLength " + ((byte[]) (param.args)[0]).length);
byte[] bitmapdata = ((byte[]) (param.args)[0]);
Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapdata, 0, bitmapdata.length);
XposedBridge.log("CamHook: StorageState: " + Environment.getExternalStorageState());
XposedBridge.log("CamHook: StoragePath: " + Environment.getExternalStorageDirectory().getAbsolutePath());
XposedBridge.log("CamHook: StoragePathEnv: " + System.getenv("EXTERNAL_STORAGE"));
//Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/input.jpg");
XposedBridge.log("CamHook: Bitmap is null: " + (bitmap == null));
bitmap = toGrayscale(bitmap);
ByteArrayOutputStream blob = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 0, blob);
param.args[0] = blob.toByteArray();
}
/*@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// this will be called after the clock was updated by the original method
}*/
});
}
public Bitmap toGrayscale(Bitmap bmpOriginal)
{
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bmpOriginal, 0, 0, paint);
return bmpGrayscale;
}
}
Does this mean it's working? App settings and YouTube adaway seem to work. But I know app settings can work without xposed
Did you get this to work?
Hi,
I found your thread. Did you ever get this to work?
Kind regards!
Hello did it work out for you? I am also looking into similar thing.
سلام

[GENERAL KNOWLEDGE]View files/resources a 3rd party app read/writes to

Hello all,
Just curious about some general knowledge (salute; reference: HIMYM) on whether or not it's possible to see what an app is doing (during installation, in the background, app initialization, and foreground usage)
It's not my own app in question so I understand physically seeing the code is out of the question; however I'm more concerned about what the app is doing and the files/directories it accesses, and whether or not there's a way for me to view these activities.
If you must know, the app in question is the Adidas Confirmed app as RootCloak (and various other apps) DO NOT WORK. I'm attempting to isolate the issue, and I'm fairly certain it has to do with an external resource (within the device; i.e. different partition, files, folders, etc.) that permanently marks the device 'rooted' during initial installation. Maybe if I can see exactly what the app reaches out to, I can then come up with a fix action.
Any input would be greatly appreciated.
You could try to decompile this app, but it might not work very well if the app obfuscates the code http://decompileandroid.com/
Rijul.A said:
You could try to decompile this app, but it might not work very well if the app obfuscates the code http://decompileandroid.com/
Click to expand...
Click to collapse
This actually worked PERFECTLY. I was able to go inside the src and see exactly the commands the app calls for to check root.
If anyone is interested...I'm going to try a few things out, play with some variables and see if I can't allow the app access on my rooted device.
Code:
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: braces fieldsfirst space lnc
package com.gpshopper.adidas.objects;
import android.os.Build;
import java.io.File;
// Referenced classes of package com.gpshopper.adidas.objects:
// ExecShell
public class Root
{
private static String LOG_TAG = com/gpshopper/adidas/objects/Root.getName();
public Root()
{
}
public static boolean checkRootMethod1()
{
String s = Build.TAGS;
return s != null && s.contains("test-keys");
}
public static boolean checkRootMethod2()
{
label0:
{
label1:
{
boolean flag = false;
boolean flag1;
try
{
File file = new File("/system/app/Superuser.apk");
File file1 = new File("/system/app/SuperSU/SuperSU.apk");
if (file.exists())
{
break label1;
}
flag1 = file1.exists();
}
catch (Exception exception)
{
return false;
}
if (!flag1)
{
break label0;
}
}
flag = true;
}
return flag;
}
public static boolean checkRootMethod3()
{
return (new ExecShell()).executeCommand(ExecShell.SHELL_CMD.check_su_binary) != null;
}
public static boolean isDeviceRooted()
{
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
}
}
There is a similar file also in the src using a different language I've not yet been able to comprehend. I'm really new at this in case you couldn't already figure lol...is it possible to view my device's database where apps store variables? It may be possible the app is permanently storing the variable even after its removal so best case would be to start from a fresh ROM install. Just a theory.
The other language is generally irrelevant
Delete /data/data/<packagename>/ or clear app data normally, that will work, no need for a fresh install.
If you need help hooking this method, please quote me in a reply.

Categories

Resources