Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intents: add the very beginnings of an intents class
Implemented as a singleton, this will eventually have functions for setting up receivers, callbacks, etc. Also, our broadcasting can move into here, to clean up some of the mess in XBMCApp.
- Loading branch information
Cory Fields
committed
Mar 1, 2013
1 parent
d76fff5
commit 7672948
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2013 Team XBMC | ||
* http://www.xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#include "Intents.h" | ||
#include "utils/log.h" | ||
#include "XBMCApp.h" | ||
|
||
CAndroidIntents::CAndroidIntents() | ||
{ | ||
} | ||
|
||
void CAndroidIntents::ReceiveIntent(JNIEnv *env, const jobject &intent) | ||
{ | ||
std::string action = GetIntentAction(intent); | ||
CLog::Log(LOGDEBUG,"CAndroidIntents::ReceiveIntent: %s", action.c_str()); | ||
} | ||
|
||
std::string CAndroidIntents::GetIntentAction(const jobject &intent) | ||
{ | ||
std::string action; | ||
JNIEnv *env; | ||
|
||
if (!intent) | ||
return ""; | ||
|
||
CXBMCApp::AttachCurrentThread(&env, NULL); | ||
jclass cIntent = env->GetObjectClass(intent); | ||
|
||
//action = intent.getAction() | ||
jmethodID mgetAction = env->GetMethodID(cIntent, "getAction", "()Ljava/lang/String;"); | ||
env->DeleteLocalRef(cIntent); | ||
jstring sAction = (jstring)env->CallObjectMethod(intent, mgetAction); | ||
const char *nativeString = env->GetStringUTFChars(sAction, 0); | ||
action = std::string(nativeString); | ||
|
||
env->ReleaseStringUTFChars(sAction, nativeString); | ||
CXBMCApp::DetachCurrentThread(); | ||
return action; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2013 Team XBMC | ||
* http://www.xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#include <string> | ||
#include <jni.h> | ||
|
||
class CAndroidIntents | ||
{ | ||
public: | ||
void ReceiveIntent(JNIEnv *env, const jobject &intent); | ||
static CAndroidIntents& getInstance() {static CAndroidIntents temp; return temp;}; | ||
|
||
private: | ||
CAndroidIntents(); | ||
CAndroidIntents(CAndroidIntents const&); | ||
void operator=(CAndroidIntents const&); | ||
std::string GetIntentAction(const jobject &intent); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters