Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > by-pkgid > 6282078ae76a671f49c6af38c67b1a07 > files > 551

kdelibs-devel-2.2.2-49.2mdk.i586.rpm

<HTML>
<HEAD>
<TITLE>class KUniqueApplication</TITLE>

<META NAME="Generator" CONTENT="KDOC ">
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
<TABLE WIDTH="100%" BORDER="0">
<TR>
<TD>
	<TABLE BORDER="0">
		<TR><TD valign="top" align="left" cellspacing="10">
		<h1>class KUniqueApplication</h1>
		</TD>
		<TD valign="top" align="right" colspan="1">
 Maintain only a single
 instance of a running application at a time. <small><A HREF="#longdesc">More...</A></small></TD></TR>
	</TABLE>
	<HR>
	<TABLE BORDER="0">
		<TR><TH>Definition</TH><TD><code>#include &lt;<A HREF="kuniqueapp_h.html">kuniqueapp.h</A>&gt;</code></TD></TR>
<TR><TH>Inherits</TH><TD><A HREF="../dcop/DCOPObject.html">DCOPObject</A> <small>(dcop)</small> <small>[public ]</small>, <A HREF="KApplication.html">KApplication</A> <small>[public ]</small></TD></TR>
<TR><TH><A HREF="full-list-KUniqueApplication.html">List of all Methods</A></TH></TR>
	</TABLE>
	</TD>
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR>
<TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR>
<TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR>
<TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR>
<TR><TD><small><A HREF="index.html">Index</A></small></TD></TR>
</TABLE></TD></TR></TABLE>
<h4>Public Methods</h4><ul><LI>&nbsp;<b><A HREF="#ref1">KUniqueApplication</A></b> ( bool allowStyles, 
		      bool GUIenabled,
		      bool configUnique) 
</LI>
<LI>&nbsp;<b><A HREF="#ref2">KUniqueApplication</A></b> ( bool allowStyles=true, 
		      bool GUIenabled=true) 
</LI>
<LI>virtual  &nbsp;<b><A HREF="#ref5">~KUniqueApplication</A></b> () 
</LI>
<LI>virtual  <A HREF="../dcop/DCOPClient.html">DCOPClient</A> *&nbsp;<b><A HREF="#ref6">dcopClient</A></b> () 
</LI>
<LI>bool &nbsp;<b><A HREF="#ref7">process</A></b> (const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &fun, const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qbytearray.html">QByteArray</A> &data,
	       <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &replyType, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qbytearray.html">QByteArray</A> &replyData) 
</LI>
<LI>virtual  int &nbsp;<b><A HREF="#ref8">newInstance</A></b> () 
</LI>
</ul><h4>Public Static Methods</h4><ul><LI>static  void &nbsp;<b><A HREF="#ref3">addCmdLineOptions</A></b> () 
</LI>
<LI>static  bool &nbsp;<b><A HREF="#ref4">start</A></b> () 
</LI>
</ul><HR><H2><A NAME="longdesc">Detailed Description</A></H2><p>
 Maintain only a single
 instance of a running application at a time.
</p>
<p> 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.
</p>
<p></p>
<p><b>See also</b>: <A HREF="KApplication.html">KApplication</A>, <A HREF="../dcop/DCOPObject.html">DCOPObject</A></p>
<A NAME="KUniqueApplication"></A><A NAME="ref1"></A><table width="100%"><tr bgcolor="#eeeeee"><td>&nbsp;<strong>KUniqueApplication</strong> ( bool allowStyles, 
		      bool GUIenabled,
		      bool configUnique)
<br></td><td align="right"><h3><strong>KUniqueApplication</strong></h3></td></tr></table><p></p><p>
 Constructor. Takes command line arguments from KCmdLineArgs
 Parameters : See <A HREF="KApplication.html">KApplication</A> constructor.
 <code>configUnique</code> 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.
</p>
<p>   </p>
<A NAME="KUniqueApplication"></A><A NAME="ref2"></A><table width="100%"><tr bgcolor="#eeeeee"><td>&nbsp;<strong>KUniqueApplication</strong> ( bool allowStyles=true, 
		      bool GUIenabled=true)
<br></td><td align="right"><h3><strong>KUniqueApplication</strong></h3></td></tr></table><p></p><A NAME="addCmdLineOptions"></A><A NAME="ref3"></A><table width="100%"><tr bgcolor="#eeeeee"><td> void &nbsp;<strong>addCmdLineOptions</strong> ()
<br></td><td align="right"><h3><strong>addCmdLineOptions</strong></h3></td></tr></table><p> <small>[static]</small></p><p>
 Add command line options specific for KUniqueApplication
</p>
<p> Should be called before calling KUniqueApplication constructor
 and / or start().
   </p>
<p>Reimplemented from <A HREF="KApplication.html#addCmdLineOptions">KApplication</A>.</p>
<A NAME="start"></A><A NAME="ref4"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool &nbsp;<strong>start</strong> ()
<br></td><td align="right"><h3><strong>start</strong></h3></td></tr></table><p> <small>[static]</small></p><p>
 Fork and register with dcop.
</p>
<p> The command line arguments are being sent via DCOP to <A HREF="KUniqueApplication.html#newInstance">newInstance</A>()
 and will be received once the application enters the event loop.
</p>
<p> Typically this is used like:
</p><table border="0" width="100%">
<tr>
<td bgcolor="#BEEAE0">
<pre>

 int main(int argc, char **argv) {
    <A HREF="KAboutData.html">KAboutData</A> about("myappname", "myAppName", .....);
    <A HREF="KCmdLineArgs.html#init">KCmdLineArgs::init</A>(argc, argv, &about);
    <A HREF="KCmdLineArgs.html#addCmdLineOptions">KCmdLineArgs::addCmdLineOptions</A>( myCmdOptions );
    KUniqueApplication::addCmdLineOptions();

    if (!KUniqueApplication::start()) {
       fprintf(stderr, "myAppName is already running!\n");
       exit(0);
    }
    <A HREF="KUniqueApplication.html#KUniqueApplication">KUniqueApplication</A> a;
    a.exec();
 }

</pre>
</td></tr>

</table> <p>
 or
</p><table border="0" width="100%">
<tr>
<td bgcolor="#BEEAE0">
<pre>

 int main(int argc, char **argv) {
    <A HREF="KAboutData.html">KAboutData</A> about("myappname", "myAppName", .....);
    <A HREF="KCmdLineArgs.html#init">KCmdLineArgs::init</A>(argc, argv, &about);
    <A HREF="KCmdLineArgs.html#addCmdLineOptions">KCmdLineArgs::addCmdLineOptions</A>( myCmdOptions );
    KUniqueApplication::addCmdLineOptions();

    if (!KUniqueApplication::start())
       exit(0);
    <A HREF="KUniqueApplication.html#KUniqueApplication">KUniqueApplication</A> a;
    a.exec();
 }

</pre>
</td></tr>

</table> <p>
 Although it is not necassery to call <A HREF="KUniqueApplication.html#start">start</A>() before creating a
 <A HREF="KUniqueApplication.html#KUniqueApplication">KUniqueApplication</A> it is adviced to so because it is about
 40% faster if the application was already running: 
 If you use <A HREF="KUniqueApplication.html#start">start</A>() the <A HREF="KApplication.html">KApplication</A> constructor will not be 
 called if this isn't necessary.
   </p>
<p><b>Returns</b>: <code>true</code> if registration is succesful.
         <code>false</code> if another process was already running.
</p>
<A NAME="~KUniqueApplication"></A><A NAME="ref5"></A><table width="100%"><tr bgcolor="#eeeeee"><td> &nbsp;<strong>~KUniqueApplication</strong> ()
<br></td><td align="right"><h3><strong>~KUniqueApplication</strong></h3></td></tr></table><p> <small>[virtual]</small></p><A NAME="dcopClient"></A><A NAME="ref6"></A><table width="100%"><tr bgcolor="#eeeeee"><td> <A HREF="../dcop/DCOPClient.html">DCOPClient</A> *&nbsp;<strong>dcopClient</strong> ()
<br></td><td align="right"><h3><strong>dcopClient</strong></h3></td></tr></table><p> <small>[virtual]</small></p><p>
 Retrieve the DCOP client object.
</p>
<p>Reimplemented from <A HREF="KApplication.html#dcopClient">KApplication</A>.</p>
<A NAME="process"></A><A NAME="ref7"></A><table width="100%"><tr bgcolor="#eeeeee"><td>bool &nbsp;<strong>process</strong> (const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &fun, const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qbytearray.html">QByteArray</A> &data,
	       <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &replyType, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qbytearray.html">QByteArray</A> &replyData)
<br></td><td align="right"><h3><strong>process</strong></h3></td></tr></table><p></p><p> 
 Dispatch any incoming DCOP message for a new instance.
</p>
<p> If it is not a request for a new instance, return <code>false</code>.
   </p>
<p>Reimplemented from <A HREF="../dcop/DCOPObject.html#process">DCOPObject</A>.</p>
<A NAME="newInstance"></A><A NAME="ref8"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int &nbsp;<strong>newInstance</strong> ()
<br></td><td align="right"><h3><strong>newInstance</strong></h3></td></tr></table><p> <small>[virtual]</small></p><p>
 Create a new "instance" of the application.
</p>
<p> 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.
</p>
<p> Command line arguments have been passed to KCmdLineArgs before this
 function is called and can be checked in the usual way.
</p>
<p></p>
<p><b>Returns</b>: An exit value. The calling process will exit with this value.
   </p>
<HR><UL><LI><i>Author</i>: Preston Brown <pbrown@kde.org>
 </LI><LI><i>Generated</i>: qateam on updates.mandrakesoft.com on Mon Dec 30 16:08:56 2002, using kdoc 2.0a53.</LI></UL></BODY></HTML>