From b715a8c430728fc0630d98c18786663dc0f380c1 Mon Sep 17 00:00:00 2001 From: damencho Date: Tue, 22 Dec 2015 15:40:50 -0600 Subject: Updates loadLibrary to be able to use native libraries from within the bundle. --- .../sysactivity/SystemActivityNotifications.java | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java') diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java index a6ff936..f4f6ede 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java @@ -1,23 +1,24 @@ /* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Copyright @ 2015 Atlassian Pty Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Copyright @ 2015 Atlassian Pty Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package net.java.sip.communicator.impl.sysactivity; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; +import org.jitsi.util.*; /** * @author Damian Minkov @@ -113,7 +114,8 @@ public class SystemActivityNotifications // Don't load native library on Android to prevent the exception if(!org.jitsi.util.OSUtils.IS_ANDROID) { - System.loadLibrary("sysactivitynotifications"); + JNIUtils.loadLibrary("sysactivitynotifications", + SystemActivityNotifications.class.getClassLoader()); ptr = allocAndInit(); if (ptr == -1) -- cgit v1.1 From be0540e2b75cc30d437daad88cb3467580eff0cc Mon Sep 17 00:00:00 2001 From: Ingo Bauersachs Date: Sun, 28 Feb 2016 21:54:06 +0100 Subject: Normalize line endings See also #227 --- .../sysactivity/SystemActivityNotifications.java | 502 ++++++++++----------- 1 file changed, 251 insertions(+), 251 deletions(-) (limited to 'src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java') diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java index f4f6ede..6d9edda 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java @@ -1,251 +1,251 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Copyright @ 2015 Atlassian Pty Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.java.sip.communicator.impl.sysactivity; - -import net.java.sip.communicator.util.Logger; -import org.jitsi.util.*; - -/** - * @author Damian Minkov - */ -public class SystemActivityNotifications -{ - /** - * The Logger used by the SystemActivityNotifications - * class to log debugging information. - */ - private static final Logger logger - = Logger.getLogger(SystemActivityNotifications.class); - - /** - * Computer display has stand by. - */ - public static final int NOTIFY_DISPLAY_SLEEP = 2; - - /** - * Computer display wakes up after stand by. - */ - public static final int NOTIFY_DISPLAY_WAKE = 3; - - /** - * A change in dns configuration has occurred. - */ - public static final int NOTIFY_DNS_CHANGE = 10; - - /** - * All processes have been informed about ending session, now notify for - * the actual end session. - */ - public static final int NOTIFY_ENDSESSION = 12; - - /** - * A change in network configuration has occurred. - */ - public static final int NOTIFY_NETWORK_CHANGE = 9; - - /** - * Notifies for start of process of ending desktop session, - * logoff or shutdown. - */ - public static final int NOTIFY_QUERY_ENDSESSION = 11; - - /** - * Screen has been locked. - */ - public static final int NOTIFY_SCREEN_LOCKED = 7; - - /** - * Screen has been unlocked. - */ - public static final int NOTIFY_SCREEN_UNLOCKED = 8; - - /** - * Screensaver has been started. - */ - public static final int NOTIFY_SCREENSAVER_START = 4; - - /** - * Screensaver has been stopped. - */ - public static final int NOTIFY_SCREENSAVER_STOP = 6; - - /** - * Screensaver will stop. - */ - public static final int NOTIFY_SCREENSAVER_WILL_STOP = 5; - - /** - * Notify that computers is going to sleep. - */ - public static final int NOTIFY_SLEEP = 0; - - /** - * Notify that computer is wakeing up after stand by. - */ - public static final int NOTIFY_WAKE = 1; - - /** - * The native instance. - */ - private static long ptr; - - /** - * Init native library. - */ - static - { - try - { - // Don't load native library on Android to prevent the exception - if(!org.jitsi.util.OSUtils.IS_ANDROID) - { - JNIUtils.loadLibrary("sysactivitynotifications", - SystemActivityNotifications.class.getClassLoader()); - - ptr = allocAndInit(); - if (ptr == -1) - ptr = 0; - } - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - else - logger.warn("Failed to initialize native counterpart", t); - } - } - - /** - * Allocate native resources and gets a pointer. - * - * @return - */ - private static native long allocAndInit(); - - /** - * Returns the when was last input in milliseconds. The time when there was - * any activity on the computer. - * - * @return the last input in milliseconds - */ - public static native long getLastInput(); - - /** - * Whether native library is loaded. - * - * @return whether native library is loaded. - */ - public static boolean isLoaded() - { - return (ptr != 0); - } - - /** - * Release native resources. - * - * @param ptr - */ - private static native void release(long ptr); - - /** - * Sets notifier delegate. - * - * @param ptr - * @param delegate - */ - public static native void setDelegate( - long ptr, - NotificationsDelegate delegate); - - /** - * Sets delegate. - * - * @param delegate - */ - public static void setDelegate(NotificationsDelegate delegate) - { - if (ptr != 0) - setDelegate(ptr, delegate); - } - - /** - * Start. - */ - public static void start() - { - if (ptr != 0) - start(ptr); - } - - /** - * Start processing. - * - * @param ptr - */ - private static native void start(long ptr); - - /** - * Stop. - */ - public static void stop() - { - if (ptr != 0) - { - stop(ptr); - release(ptr); - ptr = 0; - } - } - - /** - * Stop processing. - * - * @param ptr - */ - private static native void stop(long ptr); - - /** - * Delegate class to be notified about changes. - */ - public interface NotificationsDelegate - { - /** - * Callback method when receiving notifications. - * - * @param type - */ - public void notify(int type); - - /** - * Callback method when receiving special network notifications. - * - * @param family family of network change (ipv6, ipv4) - * @param luidIndex unique index of interface - * @param name name of the interface - * @param type of the interface - * @param connected whether interface is connected or not. - */ - public void notifyNetworkChange( - int family, - long luidIndex, - String name, - long type, - boolean connected); - } -} +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Copyright @ 2015 Atlassian Pty Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.java.sip.communicator.impl.sysactivity; + +import net.java.sip.communicator.util.Logger; +import org.jitsi.util.*; + +/** + * @author Damian Minkov + */ +public class SystemActivityNotifications +{ + /** + * The Logger used by the SystemActivityNotifications + * class to log debugging information. + */ + private static final Logger logger + = Logger.getLogger(SystemActivityNotifications.class); + + /** + * Computer display has stand by. + */ + public static final int NOTIFY_DISPLAY_SLEEP = 2; + + /** + * Computer display wakes up after stand by. + */ + public static final int NOTIFY_DISPLAY_WAKE = 3; + + /** + * A change in dns configuration has occurred. + */ + public static final int NOTIFY_DNS_CHANGE = 10; + + /** + * All processes have been informed about ending session, now notify for + * the actual end session. + */ + public static final int NOTIFY_ENDSESSION = 12; + + /** + * A change in network configuration has occurred. + */ + public static final int NOTIFY_NETWORK_CHANGE = 9; + + /** + * Notifies for start of process of ending desktop session, + * logoff or shutdown. + */ + public static final int NOTIFY_QUERY_ENDSESSION = 11; + + /** + * Screen has been locked. + */ + public static final int NOTIFY_SCREEN_LOCKED = 7; + + /** + * Screen has been unlocked. + */ + public static final int NOTIFY_SCREEN_UNLOCKED = 8; + + /** + * Screensaver has been started. + */ + public static final int NOTIFY_SCREENSAVER_START = 4; + + /** + * Screensaver has been stopped. + */ + public static final int NOTIFY_SCREENSAVER_STOP = 6; + + /** + * Screensaver will stop. + */ + public static final int NOTIFY_SCREENSAVER_WILL_STOP = 5; + + /** + * Notify that computers is going to sleep. + */ + public static final int NOTIFY_SLEEP = 0; + + /** + * Notify that computer is wakeing up after stand by. + */ + public static final int NOTIFY_WAKE = 1; + + /** + * The native instance. + */ + private static long ptr; + + /** + * Init native library. + */ + static + { + try + { + // Don't load native library on Android to prevent the exception + if(!org.jitsi.util.OSUtils.IS_ANDROID) + { + JNIUtils.loadLibrary("sysactivitynotifications", + SystemActivityNotifications.class.getClassLoader()); + + ptr = allocAndInit(); + if (ptr == -1) + ptr = 0; + } + } + catch (Throwable t) + { + if (t instanceof ThreadDeath) + throw (ThreadDeath) t; + else + logger.warn("Failed to initialize native counterpart", t); + } + } + + /** + * Allocate native resources and gets a pointer. + * + * @return + */ + private static native long allocAndInit(); + + /** + * Returns the when was last input in milliseconds. The time when there was + * any activity on the computer. + * + * @return the last input in milliseconds + */ + public static native long getLastInput(); + + /** + * Whether native library is loaded. + * + * @return whether native library is loaded. + */ + public static boolean isLoaded() + { + return (ptr != 0); + } + + /** + * Release native resources. + * + * @param ptr + */ + private static native void release(long ptr); + + /** + * Sets notifier delegate. + * + * @param ptr + * @param delegate + */ + public static native void setDelegate( + long ptr, + NotificationsDelegate delegate); + + /** + * Sets delegate. + * + * @param delegate + */ + public static void setDelegate(NotificationsDelegate delegate) + { + if (ptr != 0) + setDelegate(ptr, delegate); + } + + /** + * Start. + */ + public static void start() + { + if (ptr != 0) + start(ptr); + } + + /** + * Start processing. + * + * @param ptr + */ + private static native void start(long ptr); + + /** + * Stop. + */ + public static void stop() + { + if (ptr != 0) + { + stop(ptr); + release(ptr); + ptr = 0; + } + } + + /** + * Stop processing. + * + * @param ptr + */ + private static native void stop(long ptr); + + /** + * Delegate class to be notified about changes. + */ + public interface NotificationsDelegate + { + /** + * Callback method when receiving notifications. + * + * @param type + */ + public void notify(int type); + + /** + * Callback method when receiving special network notifications. + * + * @param family family of network change (ipv6, ipv4) + * @param luidIndex unique index of interface + * @param name name of the interface + * @param type of the interface + * @param connected whether interface is connected or not. + */ + public void notifyNetworkChange( + int family, + long luidIndex, + String name, + long type, + boolean connected); + } +} -- cgit v1.1 From 3416d6a124fffd8545f061b326d011048ff11be1 Mon Sep 17 00:00:00 2001 From: Ingo Bauersachs Date: Sat, 7 Jan 2017 17:48:43 +0100 Subject: Load JNI lib into classloader of bundle rather than of libjitsi Needs libjitsi >= 912 Closes #288 --- .../sip/communicator/impl/sysactivity/SystemActivityNotifications.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java') diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java index 6d9edda..e2fb17a 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java @@ -115,7 +115,7 @@ public class SystemActivityNotifications if(!org.jitsi.util.OSUtils.IS_ANDROID) { JNIUtils.loadLibrary("sysactivitynotifications", - SystemActivityNotifications.class.getClassLoader()); + SystemActivityNotifications.class); ptr = allocAndInit(); if (ptr == -1) -- cgit v1.1