| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_CLIENT_JNI_JNI_CLIENT_H_ | 5 #ifndef REMOTING_CLIENT_JNI_JNI_CLIENT_H_ |
| 6 #define REMOTING_CLIENT_JNI_JNI_CLIENT_H_ | 6 #define REMOTING_CLIENT_JNI_JNI_CLIENT_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Houses resources scoped to a session and exposes JNI interface to the | 23 // Houses resources scoped to a session and exposes JNI interface to the |
| 24 // Java client during a session. All its methods should be invoked exclusively | 24 // Java client during a session. All its methods should be invoked exclusively |
| 25 // from the UI thread unless otherwise noted. | 25 // from the UI thread unless otherwise noted. |
| 26 class JniClient { | 26 class JniClient { |
| 27 public: | 27 public: |
| 28 JniClient(ChromotingJniRuntime* runtime, | 28 JniClient(ChromotingJniRuntime* runtime, |
| 29 base::android::ScopedJavaGlobalRef<jobject> java_client); | 29 base::android::ScopedJavaGlobalRef<jobject> java_client); |
| 30 virtual ~JniClient(); | 30 virtual ~JniClient(); |
| 31 | 31 |
| 32 // TODO(yuweih): Put these arguments into a struct. |
| 32 // Initiates a connection with the specified host. To skip the attempt at | 33 // Initiates a connection with the specified host. To skip the attempt at |
| 33 // pair-based authentication, leave |pairing_id| and |pairing_secret| as | 34 // pair-based authentication, leave |pairing_id| and |pairing_secret| as |
| 34 // empty strings. | 35 // empty strings. |
| 35 void ConnectToHost(const std::string& username, | 36 void ConnectToHost(const std::string& username, |
| 36 const std::string& auth_token, | 37 const std::string& auth_token, |
| 37 const std::string& host_jid, | 38 const std::string& host_jid, |
| 38 const std::string& host_id, | 39 const std::string& host_id, |
| 39 const std::string& host_pubkey, | 40 const std::string& host_pubkey, |
| 40 const std::string& pairing_id, | 41 const std::string& pairing_id, |
| 41 const std::string& pairing_secret, | 42 const std::string& pairing_secret, |
| 42 const std::string& capabilities, | 43 const std::string& capabilities, |
| 43 const std::string& flags); | 44 const std::string& flags, |
| 45 const std::string& host_version, |
| 46 const std::string& host_os, |
| 47 const std::string& host_os_version); |
| 44 | 48 |
| 45 // Terminates any ongoing connection attempt and cleans up by nullifying | 49 // Terminates any ongoing connection attempt and cleans up by nullifying |
| 46 // |session_|. This is a no-op unless |session| is currently non-null. | 50 // |session_|. This is a no-op unless |session| is currently non-null. |
| 47 void DisconnectFromHost(); | 51 void DisconnectFromHost(); |
| 48 | 52 |
| 49 // Notifies Java code of the current connection status. Call on UI thread. | 53 // Notifies Java code of the current connection status. Call on UI thread. |
| 50 void OnConnectionState(protocol::ConnectionToHost::State state, | 54 void OnConnectionState(protocol::ConnectionToHost::State state, |
| 51 protocol::ErrorCode error); | 55 protocol::ErrorCode error); |
| 52 | 56 |
| 53 // Pops up a dialog box asking the user to enter a PIN. Call on UI thread. | 57 // Pops up a dialog box asking the user to enter a PIN. Call on UI thread. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 80 void Connect(JNIEnv* env, | 84 void Connect(JNIEnv* env, |
| 81 const base::android::JavaParamRef<jobject>& caller, | 85 const base::android::JavaParamRef<jobject>& caller, |
| 82 const base::android::JavaParamRef<jstring>& username, | 86 const base::android::JavaParamRef<jstring>& username, |
| 83 const base::android::JavaParamRef<jstring>& authToken, | 87 const base::android::JavaParamRef<jstring>& authToken, |
| 84 const base::android::JavaParamRef<jstring>& hostJid, | 88 const base::android::JavaParamRef<jstring>& hostJid, |
| 85 const base::android::JavaParamRef<jstring>& hostId, | 89 const base::android::JavaParamRef<jstring>& hostId, |
| 86 const base::android::JavaParamRef<jstring>& hostPubkey, | 90 const base::android::JavaParamRef<jstring>& hostPubkey, |
| 87 const base::android::JavaParamRef<jstring>& pairId, | 91 const base::android::JavaParamRef<jstring>& pairId, |
| 88 const base::android::JavaParamRef<jstring>& pairSecret, | 92 const base::android::JavaParamRef<jstring>& pairSecret, |
| 89 const base::android::JavaParamRef<jstring>& capabilities, | 93 const base::android::JavaParamRef<jstring>& capabilities, |
| 90 const base::android::JavaParamRef<jstring>& flags); | 94 const base::android::JavaParamRef<jstring>& flags, |
| 95 const base::android::JavaParamRef<jstring>& host_version, |
| 96 const base::android::JavaParamRef<jstring>& host_os, |
| 97 const base::android::JavaParamRef<jstring>& host_os_version); |
| 91 | 98 |
| 92 void Disconnect(JNIEnv* env, | 99 void Disconnect(JNIEnv* env, |
| 93 const base::android::JavaParamRef<jobject>& caller); | 100 const base::android::JavaParamRef<jobject>& caller); |
| 94 | 101 |
| 95 void AuthenticationResponse( | 102 void AuthenticationResponse( |
| 96 JNIEnv* env, | 103 JNIEnv* env, |
| 97 const base::android::JavaParamRef<jobject>& caller, | 104 const base::android::JavaParamRef<jobject>& caller, |
| 98 const base::android::JavaParamRef<jstring>& pin, | 105 const base::android::JavaParamRef<jstring>& pin, |
| 99 jboolean createPair, | 106 jboolean createPair, |
| 100 const base::android::JavaParamRef<jstring>& deviceName); | 107 const base::android::JavaParamRef<jstring>& deviceName); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Holds pointer for the UI thread. | 174 // Holds pointer for the UI thread. |
| 168 base::WeakPtr<JniClient> weak_ptr_; | 175 base::WeakPtr<JniClient> weak_ptr_; |
| 169 base::WeakPtrFactory<JniClient> weak_factory_; | 176 base::WeakPtrFactory<JniClient> weak_factory_; |
| 170 | 177 |
| 171 DISALLOW_COPY_AND_ASSIGN(JniClient); | 178 DISALLOW_COPY_AND_ASSIGN(JniClient); |
| 172 }; | 179 }; |
| 173 | 180 |
| 174 } // namespace remoting | 181 } // namespace remoting |
| 175 | 182 |
| 176 #endif // REMOTING_CLIENT_JNI_JNI_CLIENT_H_ | 183 #endif // REMOTING_CLIENT_JNI_JNI_CLIENT_H_ |
| OLD | NEW |