summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/org/kde/koala/KUniqueApplication.java
blob: 0955b94163d9e1a60276567a656f70b9efb06436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;

import org.kde.qt.Qt;
import org.kde.qt.TQMetaObject;
import org.kde.qt.QtSupport;
import org.kde.qt.TQObject;
import java.util.ArrayList;

/**

 Maintains only a single
 instance of a running application at a time.
 If another instance
 is started, it will determine (via DCOP) whether it is the first instance
 or a second instance.  If it is a second instance, it will forward on
 the information to the first instance and then quit.
 The .desktop file for the application should state X-DCOP-ServiceType=Unique,
 see kapplication.h
 If your application is used to open files, it should also support the --tempfile
 option (see KCmdLineArgs.addTempFileOption()), to delete tempfiles after use.
 Add X-TDE-HasTempFileOption=true to the .desktop file to indicate this.
		@author Preston Brown <pbrown@kde.org>
 
		@short    Maintains only a single  instance of a running application at a time.
		@see KApplication
		@see DCOPObject

*/
public class KUniqueApplication extends KApplication implements DCOPObjectInterface {
	protected KUniqueApplication(Class dummy){super((Class) null);}
	public native TQMetaObject metaObject();
	public native String className();
	/**	
		 Constructor. Takes command line arguments from KCmdLineArgs
			@param allowStyles Set to false to disable the loading on plugin based
		 styles. This is only useful to applications that do not display a GUI
		 normally. If you do create an application with <code>allowStyles</code> set to false
		 it normally runs in the background but under special circumstances
		 displays widgets.  Call KApplication.enableStyles() before 
		 displaying any widgets.
			@param GUIenabled Set to false to disable all GUI stuff. This implies
		 no styles either.
			@param configUnique If true, the uniqueness of the application will
		                 depend on the value of the "MultipleInstances"
		                 key in the "KDE" group of the application config file.
		   		@short    Constructor.
	*/
	public KUniqueApplication(boolean allowStyles, boolean GUIenabled, boolean configUnique) {
		super((Class) null);
		newKUniqueApplication(allowStyles,GUIenabled,configUnique);
	}
	private native void newKUniqueApplication(boolean allowStyles, boolean GUIenabled, boolean configUnique);
	public KUniqueApplication(boolean allowStyles, boolean GUIenabled) {
		super((Class) null);
		newKUniqueApplication(allowStyles,GUIenabled);
	}
	private native void newKUniqueApplication(boolean allowStyles, boolean GUIenabled);
	public KUniqueApplication(boolean allowStyles) {
		super((Class) null);
		newKUniqueApplication(allowStyles);
	}
	private native void newKUniqueApplication(boolean allowStyles);
	public KUniqueApplication() {
		super((Class) null);
		newKUniqueApplication();
	}
	private native void newKUniqueApplication();
	/**	
		 Dispatches any incoming DCOP message for a new instance.
			 If it is not a request for a new instance, return false.
		 Overloaded from DCOPObject to make sure that the application
		 stays unique.
			@param fun DCOP function signature
			@param data the data for the arguments
			@param replyType the type of the reply value
			@param replyData the reply
				@short    Dispatches any incoming DCOP message for a new instance.
		@see DCOPObject
	*/
	public native boolean process(String fun, byte[] data, StringBuffer replyType, byte[] replyData);
	/**	
		 Creates a new "instance" of the application.
			 Usually this will involve making some calls into the GUI portion of your
		 application asking for a new window to be created, possibly with
		 some data already loaded based on the arguments received.
			 Command line arguments have been passed to KCmdLineArgs before this
		 function is called and can be checked in the usual way.
			 The default implementation ensures the mainwindow of the already
		 running instance is shown and activated if necessary. You should
		 prefer using it from your overridden method instead of doing
		 it directly.
			 Note that newInstance() is called also in the first started 
		 application process.
				@return An exit value. The calling process will exit with this value.
   
		@short    Creates a new "instance" of the application.
	*/
	public native int newInstance();
	/**	
		 Returns whether newInstance() is being called while session
		 restoration is in progress.
				@short    Returns whether newInstance() is being called while session  restoration is in progress.
	*/
	public native boolean restoringSession();
	/**	
		 Adds command line options specific for KUniqueApplication.
			 Should be called before calling KUniqueApplication constructor
		 and / or start().
		   		@short    Adds command line options specific for KUniqueApplication.
	*/
	public static native void addCmdLineOptions();
	/**	
		 Forks and registers with dcop.
			 The command line arguments are being sent via DCOP to newInstance()
		 and will be received once the application enters the event loop.
			 Typically this is used like:
		 <pre>
		 int main(String[] args) {
		    KAboutData about("myappname", "myAppName", .....);
		    KCmdLineArgs.init(args, &about);
		    KCmdLineArgs.addCmdLineOptions( myCmdOptions );
		    KUniqueApplication.addCmdLineOptions();
			    if (!KUniqueApplication.start()) {
		       fprintf(stderr, "myAppName is already running!\n");
		       exit(0);
		    }
		    KUniqueApplication a;
		    a.exec();
		 }
		 </pre>
		 Note that it's not necessary to call start() explicitly. It will be
		 called automatically before creating KUniqueApplication if it hasn't
		 been called yet, without any performance impact.
				@return true if registration is successful.
         false if another process was already running.
   
		@short    Forks and registers with dcop.
	*/
	public static native boolean start();
	/**	
			   		@short
	*/
	public static native void setHandleAutoStarted();
	/** Deletes the wrapped C++ instance */
	protected native void finalize() throws InternalError;
	/** Delete the wrapped C++ instance ahead of finalize() */
	public native void dispose();
	/** Has the wrapped C++ instance been deleted? */
	public native boolean isDisposed();
	/**	
		 Returns the object id of the DCOPObject.
				@return the object's id
   
		@short    Returns the object id of the DCOPObject.
	*/
	public native String objId();
	/**	
		 Renames a dcop object, if no other with the same name exists
		 Use with care, all dcop signals are disconnected
			@param objId the new object id
				@short    Renames a dcop object, if no other with the same name exists  Use with care, all dcop signals are disconnected
	*/
	public native boolean setObjId(String objId);
	/**	
		 This function is of interest when you used an IDL compiler
		 to generate the implementation for process() but
		 you still want to dispatch some functions dynamically.
		 Dynamically means that methods may appear and vanish
		 during runtime.
			@param fun is the normalized function signature.
		            Such a signature usually looks like
		            foobar(String,int). The return type,
		            qualifiers like "const" etc. are not part of
		            the signature.
			@param data the received data
			@param replyType write the reply type in this string
			@param replyData write the reply data in this array
				@return true if successful, false otherwise. The default implementation
         returns always false.

		@short    This function is of interest when you used an IDL compiler  to generate the implementation for process() but  you still want to dispatch some functions dynamically.
		@see #process
		@see DCOPClient#normalizeFunctionSignature
		@see #functions
		@see DCOPClient#process
	*/
	public native boolean processDynamic(String fun, byte[] data, StringBuffer replyType, byte[] replyData);
	/**	
		 This function is of interest when you used an IDL compiler
		 to generate the implementation for functions() but
		 you still want to list some functions dynamically.
		 Dynamically means that the methods may appear and vanish
		 during runtime.
				@return A list of the additional functions, default is an empty list.

		@short    This function is of interest when you used an IDL compiler  to generate the implementation for functions() but  you still want to list some functions dynamically.
		@see #functions
	*/
	public native ArrayList functionsDynamic();
	/**	
		 This function is of interest when you used an IDL compiler
		 to generate the implementation for interfaces() but
		 you still want to list some interfaces dynamically.
		 Dynamically means that they may appear and vanish
		 during runtime.
				@return A list of the additional interfaces, default is an empty list.

		@short    This function is of interest when you used an IDL compiler  to generate the implementation for interfaces() but  you still want to list some interfaces dynamically.
		@see #interfaces
	*/
	public native ArrayList interfacesDynamic();
	/**	
		 Returns the names of the interfaces, specific ones last. The
		 functions gets reimplemented by the IDL compiler. If you don't
		 use the IDL compiler, consider implementing this function
		 manually if you want your object to be easily explorable.
				@return a list of interfaces

		@short    Returns the names of the interfaces, specific ones last.
		@see #functions
	*/
	public native ArrayList interfaces();
	/**	
		 Returns the list of functions understood by the object. It gets
		 reimplemented by the IDL compiler. If you don't use the IDL
		 compiler, consider implementing this function manually if you
		 want your object to be easily scriptable.
			 Rationale: functions() allows an interpreter to do client-side
		 type-casting properly.
			 Note to implementators: remember to call the baseclasses
		 implementation.
				@return a list of functions

		@short    Returns the list of functions understood by the object.
		@see #interfaces
		@see #process
		@see #processDynamic
		@see DCOPClient#normalizeFunctionSignature
	*/
	public native ArrayList functions();
	/**	
		 Emit <code>signal</code> as DCOP signal from this object with <code>data</code> as
		 arguments
			@param signal the signal to emit
			@param data the data to send
		   		@short    Emit <code>signal</code> as DCOP signal from this object with <code>data</code> as  arguments
	*/
	public native void emitDCOPSignal(String signal, byte[] data);
	/**	
		 Connects to a DCOP signal.
			@param sender the name of the client that emits the signal. When empty
		 the signal will be passed from any client.
			@param senderObj the name of the sending object that emits the signal.
			@param signal the name of the signal. The arguments should match with slot.
			@param slot The name of the slot to call. Its arguments should match with signal.
			@param Volatile If true, the connection will not be reestablished when
		 <code>sender</code> unregisters and reregisters with DCOP. In this case the <code>sender</code>
		 must be registered when the connection is made.
		 If false, the connection will be reestablished when <code>sender</code> reregisters.
		 In this case the connection can be made even if <code>sender</code> is not registered
		 at that time.
		
			<li>
			<code>Volatile</code> is true and <code>sender</code>  does not exist.
			</li>
			
			<li>
			<code>signal</code> and <code>slot</code> do not have matching arguments.
			   
			</li>		@return false if a connection could not be established.
 This will be the case when

		@short    Connects to a DCOP signal.
	*/
	public native boolean connectDCOPSignal(String sender, String senderObj, String signal, String slot, boolean Volatile);
	/**	
		 Disconnects a DCOP signal.
			 A special case is when both <code>sender</code> & <code>signal</code> are empty. In this
		 case all connections related to this object in the current client
		 are disconnected. (Both connections from as well as to this object!)
			@param sender the name of the client that emits the signal.
			@param senderObj the name of the object that emits the signal.
		 If empty all objects will be disconnected.
			@param signal the name of the signal. The arguments should match with slot.
		 If empty all objects will be disconnected.
			@param slot The name of the slot the signal is connected to.
		 If empty all slots will be disconnected.
				@return false if no connection(s) where removed.
   
		@short    Disconnects a DCOP signal.
	*/
	public native boolean disconnectDCOPSignal(String sender, String senderObj, String signal, String slot);
	/**	
		 Returns the DCOPClient responsible for making the call. 
		 Only call this function while you are handling a DCOP call.
				@return the DCOPClient responsible for making the call. 
 This information is only guaranteed to be correct when 
 entering your DCOP function.

		@short    Returns the DCOPClient responsible for making the call.
	*/
	public native DCOPClient callingDcopClient();
	/**	
				@short
	*/
	public native void setCallingDcopClient(DCOPClient arg1);
	/**	
		 Checks whether an object with the given id is known in this process.
			 DCOPObjectProxy
		   		@return true if an object with the questionable <code>objId</code> is
         known in this process. This query does not ask proxies.

		@short    Checks whether an object with the given id is known in this process.
	*/
	public static native boolean hasObject(String objId);
	/**	
		 Try to find a dcop object with the given id.
		 This function does not query the DCOPObjectProxy.
			@param objId the object id to search
				@return the  DCOPObject for the id <code>objId.</code>
   
		@short    Try to find a dcop object with the given id.
	*/
	public static native DCOPObjectInterface find(String objId);
	/**	
		 Tries to find an object using a partial object id.
		 This function is used for multicasting a DCOP message to
		 several objects inside a single process.
			@param partialId the partial object id to search for
				@return a list of DCOPObjects beginning with the string
 contained in <code>partialId.</code>
   
		@short    Tries to find an object using a partial object id.
	*/
	// TQPtrList<DCOPObject> match(const TQCString& arg1); >>>> NOT CONVERTED
	/**	
		 Creates an object id for the TQObject <code>obj.</code> This is done
		 using the TQObject.name() function.
			@param obj the object whose name will be used
				@return the created object id
   
		@short    Creates an object id for the TQObject <code>obj.</code>
	*/
	public static native String objectName(TQObject arg1);
}