xref: /aoo41x/main/framework/inc/jobs/joburl.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __FRAMEWORK_JOBS_JOBURL_HXX_
29*cdf0e10cSrcweir #define __FRAMEWORK_JOBS_JOBURL_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_______________________________________
32*cdf0e10cSrcweir // my own includes
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
35*cdf0e10cSrcweir #include <macros/debug.hxx>
36*cdf0e10cSrcweir #include <stdtypes.h>
37*cdf0e10cSrcweir #include <general.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir //_______________________________________
40*cdf0e10cSrcweir // interface includes
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //_______________________________________
43*cdf0e10cSrcweir // other includes
44*cdf0e10cSrcweir #include <rtl/ustring.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //_______________________________________
47*cdf0e10cSrcweir // namespace
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir namespace framework{
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //_______________________________________
52*cdf0e10cSrcweir // const
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #define JOBURL_PROTOCOL_STR        "vnd.sun.star.job:"
55*cdf0e10cSrcweir #define JOBURL_PROTOCOL_LEN        17
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #define JOBURL_EVENT_STR           "event="
58*cdf0e10cSrcweir #define JOBURL_EVENT_LEN           6
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #define JOBURL_ALIAS_STR           "alias="
61*cdf0e10cSrcweir #define JOBURL_ALIAS_LEN           6
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir #define JOBURL_SERVICE_STR         "service="
64*cdf0e10cSrcweir #define JOBURL_SERVICE_LEN         8
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #define JOBURL_PART_SEPERATOR      ';'
67*cdf0e10cSrcweir #define JOBURL_PARTARGS_SEPERATOR  ','
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir //_______________________________________
70*cdf0e10cSrcweir /**
71*cdf0e10cSrcweir     @short  can be used to parse, validate and work with job URL's
72*cdf0e10cSrcweir     @descr  Job URLs are specified by the following syntax:
73*cdf0e10cSrcweir                 vnd.sun.star.job:{[event=<name>]|[alias=<name>]|[service=<name>]}
74*cdf0e10cSrcweir             This class can analyze this structure and seperate it into his different parts.
75*cdf0e10cSrcweir             After doing that these parts are accessible by the methods of this class.
76*cdf0e10cSrcweir  */
77*cdf0e10cSrcweir class JobURL : private ThreadHelpBase
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir     //___________________________________
80*cdf0e10cSrcweir     // types
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     private:
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir         /**
85*cdf0e10cSrcweir             possible states of a job URL
86*cdf0e10cSrcweir             Note: These values are used in combination. So they must be
87*cdf0e10cSrcweir             values in form 2^n.
88*cdf0e10cSrcweir          */
89*cdf0e10cSrcweir         enum ERequest
90*cdf0e10cSrcweir         {
91*cdf0e10cSrcweir             /// mark a job URL as not valid
92*cdf0e10cSrcweir             E_UNKNOWN = 0,
93*cdf0e10cSrcweir             /// it's an event
94*cdf0e10cSrcweir             E_EVENT   = 1,
95*cdf0e10cSrcweir             /// it's an alias
96*cdf0e10cSrcweir             E_ALIAS   = 2,
97*cdf0e10cSrcweir             /// it's a service
98*cdf0e10cSrcweir             E_SERVICE = 4
99*cdf0e10cSrcweir         };
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     //___________________________________
102*cdf0e10cSrcweir     // types
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     private:
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir         /** knows the state of this URL instance */
107*cdf0e10cSrcweir         sal_uInt32 m_eRequest;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir         /** holds the event part of a job URL */
110*cdf0e10cSrcweir         ::rtl::OUString m_sEvent;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir         /** holds the alias part of a job URL */
113*cdf0e10cSrcweir         ::rtl::OUString m_sAlias;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir         /** holds the service part of a job URL */
116*cdf0e10cSrcweir         ::rtl::OUString m_sService;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir         /** holds the event arguments */
119*cdf0e10cSrcweir         ::rtl::OUString m_sEventArgs;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir         /** holds the alias arguments */
122*cdf0e10cSrcweir         ::rtl::OUString m_sAliasArgs;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         /** holds the service arguments */
125*cdf0e10cSrcweir         ::rtl::OUString m_sServiceArgs;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     //___________________________________
128*cdf0e10cSrcweir     // native interface
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     public:
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir                  JobURL        ( const ::rtl::OUString& sURL         );
133*cdf0e10cSrcweir         sal_Bool isValid       (                                     ) const;
134*cdf0e10cSrcweir         sal_Bool getEvent      (       ::rtl::OUString& sEvent       ) const;
135*cdf0e10cSrcweir         sal_Bool getAlias      (       ::rtl::OUString& sAlias       ) const;
136*cdf0e10cSrcweir         sal_Bool getService    (       ::rtl::OUString& sService     ) const;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     //___________________________________
139*cdf0e10cSrcweir     // private helper
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     private:
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         static sal_Bool implst_split( const ::rtl::OUString& sPart           ,
144*cdf0e10cSrcweir                                       const sal_Char*        pPartIdentifier ,
145*cdf0e10cSrcweir                                             sal_Int32        nPartLength     ,
146*cdf0e10cSrcweir                                             ::rtl::OUString& rPartValue      ,
147*cdf0e10cSrcweir                                             ::rtl::OUString& rPartArguments  );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     //___________________________________
150*cdf0e10cSrcweir     // debug methods!
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     #ifdef ENABLE_COMPONENT_SELF_CHECK
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     public:
155*cdf0e10cSrcweir         static void impldbg_checkIt();
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     private:
158*cdf0e10cSrcweir         static void impldbg_checkURL( const sal_Char*  pURL                 ,
159*cdf0e10cSrcweir                                             sal_uInt32 eExpectedPart        ,
160*cdf0e10cSrcweir                                       const sal_Char*  pExpectedEvent       ,
161*cdf0e10cSrcweir                                       const sal_Char*  pExpectedAlias       ,
162*cdf0e10cSrcweir                                       const sal_Char*  pExpectedService     ,
163*cdf0e10cSrcweir                                       const sal_Char*  pExpectedEventArgs   ,
164*cdf0e10cSrcweir                                       const sal_Char*  pExpectedAliasArgs   ,
165*cdf0e10cSrcweir                                       const sal_Char*  pExpectedServiceArgs );
166*cdf0e10cSrcweir         ::rtl::OUString impldbg_toString() const;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir         sal_Bool getServiceArgs(       ::rtl::OUString& sServiceArgs ) const;
169*cdf0e10cSrcweir         sal_Bool getEventArgs  (       ::rtl::OUString& sEventArgs   ) const;
170*cdf0e10cSrcweir         sal_Bool getAliasArgs  (       ::rtl::OUString& sAliasArgs   ) const;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     #endif // ENABLE_COMPONENT_SELF_CHECK
173*cdf0e10cSrcweir };
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir } // namespace framework
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir #endif // __FRAMEWORK_JOBS_JOBURL_HXX_
178