Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: jni/JniNotification.cpp

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Left Patch Set: Removed unused import, cleaned up formatting." Created Feb. 17, 2015, 1:54 p.m.
Right Patch Set: Only one Notification displayed now Created Feb. 18, 2015, 3:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « jni/JniFilterEngine.cpp ('k') | jni/Utils.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <AdblockPlus.h> 18 #include <AdblockPlus.h>
19 #include "Utils.h" 19 #include "Utils.h"
20 #include "JniJsValue.h" 20 #include "JniJsValue.h"
21
22 // TODO (rje) apply local_ref
Felix Dahlke 2015/02/18 12:49:56 Ah, TODO comment! :) Sounds like something that ne
René Jeschke 2015/02/18 13:13:02 Nah, was written during the local_ref review to re
23 21
24 static AdblockPlus::Notification* GetNotificationPtr(jlong ptr) 22 static AdblockPlus::Notification* GetNotificationPtr(jlong ptr)
25 { 23 {
26 return JniLongToTypePtr<AdblockPlus::NotificationPtr>(ptr)->get(); 24 return JniLongToTypePtr<AdblockPlus::NotificationPtr>(ptr)->get();
27 } 25 }
28 26
29 static jobject JNICALL JniGetType(JNIEnv* env, jclass clazz, jlong ptr) 27 static jobject JNICALL JniGetType(JNIEnv* env, jclass clazz, jlong ptr)
30 { 28 {
31 AdblockPlus::NotificationType type; 29 AdblockPlus::NotificationType type;
32 try 30 try
(...skipping 13 matching lines...) Expand all
46 enumName = "INFORMATION"; 44 enumName = "INFORMATION";
47 break; 45 break;
48 case AdblockPlus::NotificationType::NOTIFICATION_TYPE_QUESTION: 46 case AdblockPlus::NotificationType::NOTIFICATION_TYPE_QUESTION:
49 enumName = "QUESTION"; 47 enumName = "QUESTION";
50 break; 48 break;
51 default: 49 default:
52 enumName = "INVALID"; 50 enumName = "INVALID";
53 break; 51 break;
54 } 52 }
55 53
56 jclass enumClass = env->FindClass(PKG("Notification$Type")); 54 JniLocalReference<jclass> enumClass(
57 jfieldID enumField = env->GetStaticFieldID(enumClass, enumName, TYP("Notificat ion$Type")); 55 env,
58 return env->GetStaticObjectField(enumClass, enumField); 56 env->FindClass(PKG("Notification$Type")));
57
58 jfieldID enumField = env->GetStaticFieldID(
59 *enumClass,
60 enumName,
61 TYP("Notification$Type"));
62
63 return env->GetStaticObjectField(*enumClass, enumField);
59 } 64 }
60 65
61 static jstring JniGetTitle(JNIEnv* env, jclass clazz, jlong ptr) 66 static jstring JniGetTitle(JNIEnv* env, jclass clazz, jlong ptr)
62 { 67 {
63 try 68 try
64 { 69 {
65 return env->NewStringUTF(GetNotificationPtr(ptr)->GetTitle().c_str()); 70 return env->NewStringUTF(GetNotificationPtr(ptr)->GetTitle().c_str());
66 } 71 }
67 CATCH_THROW_AND_RETURN(env, 0) 72 CATCH_THROW_AND_RETURN(env, 0)
68 } 73 }
(...skipping 23 matching lines...) Expand all
92 { (char*) "getTitle", (char*) "(J)Ljava/lang/String;", (void*) JniGetTitle }, 97 { (char*) "getTitle", (char*) "(J)Ljava/lang/String;", (void*) JniGetTitle },
93 { (char*) "getType", (char*) "(J)" TYP("Notification$Type"), (void*) JniGetTyp e } 98 { (char*) "getType", (char*) "(J)" TYP("Notification$Type"), (void*) JniGetTyp e }
94 }; 99 };
95 100
96 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Notificati on_registerNatives( 101 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Notificati on_registerNatives(
97 JNIEnv *env, jclass clazz) 102 JNIEnv *env, jclass clazz)
98 { 103 {
99 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 104 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
100 } 105 }
101 106
LEFTRIGHT

Powered by Google App Engine
This is Rietveld