Commit 778ca49f authored by Geoffrey Métais's avatar Geoffrey Métais

Implement ML API update for addDevice

parent a1a3e349
......@@ -61,12 +61,11 @@ AndroidMediaLibrary::initML(const std::string& dbPath, const std::string& thumbs
return p_ml->initialize(dbPath, thumbsPath, this);
}
void
bool
AndroidMediaLibrary::addDevice(const std::string& uuid, const std::string& path, bool removable)
{
p_lister->addDevice(uuid, path, removable);
if (p_DeviceListerCb != nullptr)
p_DeviceListerCb->onDevicePlugged(uuid, path);
return p_DeviceListerCb != nullptr && p_DeviceListerCb->onDevicePlugged(uuid, path);
}
std::vector<std::tuple<std::string, std::string, bool>>
......
......@@ -29,7 +29,7 @@ public:
~AndroidMediaLibrary();
bool initML(const std::string& dbPath, const std::string& thumbsPath);
void addDevice(const std::string& uuid, const std::string& path, bool removable);
bool addDevice(const std::string& uuid, const std::string& path, bool removable);
std::vector<std::tuple<std::string, std::string, bool>> devices();
bool removeDevice(const std::string& uuid);
void banFolder(const std::string& path);
......
......@@ -57,14 +57,16 @@ banFolder(JNIEnv* env, jobject thiz, jstring folderPath)
env->ReleaseStringUTFChars(folderPath, path);
}
void addDevice(JNIEnv* env, jobject thiz, jstring uuid, jstring storagePath, jboolean removable)
jboolean
addDevice(JNIEnv* env, jobject thiz, jstring uuid, jstring storagePath, jboolean removable)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
const char *uuidChar = env->GetStringUTFChars(uuid, JNI_FALSE);
const char *path = env->GetStringUTFChars(storagePath, JNI_FALSE);
aml->addDevice(uuidChar, path, removable);
jboolean isNew = aml->addDevice(uuidChar, path, removable);
env->ReleaseStringUTFChars(uuid, uuidChar);
env->ReleaseStringUTFChars(storagePath, path);
return isNew;
}
jobjectArray
......@@ -742,7 +744,7 @@ static JNINativeMethod methods[] = {
{"nativeSetup", "()V", (void*)setup },
{"nativeInit", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)init },
{"nativeRelease", "()V", (void*)release },
{"nativeAddDevice", "(Ljava/lang/String;Ljava/lang/String;Z)V", (void*)addDevice },
{"nativeAddDevice", "(Ljava/lang/String;Ljava/lang/String;Z)Z", (void*)addDevice },
{"nativeDevices", "()[Ljava/lang/String;", (void*)devices },
{"nativeDiscover", "(Ljava/lang/String;)V", (void*)discover },
{"nativeRemoveEntryPoint", "(Ljava/lang/String;)V", (void*)removeEntryPoint },
......
......@@ -83,8 +83,8 @@ public class Medialibrary {
return mIsInitiated ? nativeDevices() : new String[0];
}
public void addDevice(String uuid, String path, boolean removable) {
nativeAddDevice(uuid, Tools.encodeVLCMrl(path), removable);
public boolean addDevice(String uuid, String path, boolean removable) {
return nativeAddDevice(uuid, Tools.encodeVLCMrl(path), removable);
}
public void discover(String path) {
......@@ -538,7 +538,7 @@ public class Medialibrary {
private native boolean nativeInit(String dbPath, String thumbsPath);
private native void nativeRelease();
private native void nativeBanFolder(String path);
private native void nativeAddDevice(String uuid, String path, boolean removable);
private native boolean nativeAddDevice(String uuid, String path, boolean removable);
private native String[] nativeDevices();
private native void nativeDiscover(String path);
private native void nativeRemoveEntryPoint(String path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment