xref: /aoo42x/main/framework/inc/jobs/joburl.hxx (revision 07a3d7f1)
1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_JOBS_JOBURL_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_JOBS_JOBURL_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________
28cdf0e10cSrcweir // my own includes
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
31cdf0e10cSrcweir #include <macros/debug.hxx>
32cdf0e10cSrcweir #include <stdtypes.h>
33cdf0e10cSrcweir #include <general.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //_______________________________________
36cdf0e10cSrcweir // interface includes
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //_______________________________________
39cdf0e10cSrcweir // other includes
40cdf0e10cSrcweir #include <rtl/ustring.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //_______________________________________
43cdf0e10cSrcweir // namespace
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace framework{
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //_______________________________________
48cdf0e10cSrcweir // const
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #define JOBURL_PROTOCOL_STR        "vnd.sun.star.job:"
51cdf0e10cSrcweir #define JOBURL_PROTOCOL_LEN        17
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #define JOBURL_EVENT_STR           "event="
54cdf0e10cSrcweir #define JOBURL_EVENT_LEN           6
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #define JOBURL_ALIAS_STR           "alias="
57cdf0e10cSrcweir #define JOBURL_ALIAS_LEN           6
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define JOBURL_SERVICE_STR         "service="
60cdf0e10cSrcweir #define JOBURL_SERVICE_LEN         8
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #define JOBURL_PART_SEPERATOR      ';'
63cdf0e10cSrcweir #define JOBURL_PARTARGS_SEPERATOR  ','
64cdf0e10cSrcweir 
65cdf0e10cSrcweir //_______________________________________
66cdf0e10cSrcweir /**
67cdf0e10cSrcweir     @short  can be used to parse, validate and work with job URL's
68cdf0e10cSrcweir     @descr  Job URLs are specified by the following syntax:
69cdf0e10cSrcweir                 vnd.sun.star.job:{[event=<name>]|[alias=<name>]|[service=<name>]}
70*07a3d7f1SPedro Giffuni             This class can analyze this structure and separate it into his different parts.
71cdf0e10cSrcweir             After doing that these parts are accessible by the methods of this class.
72cdf0e10cSrcweir  */
73cdf0e10cSrcweir class JobURL : private ThreadHelpBase
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     //___________________________________
76cdf0e10cSrcweir     // types
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     private:
79cdf0e10cSrcweir 
80cdf0e10cSrcweir         /**
81cdf0e10cSrcweir             possible states of a job URL
82cdf0e10cSrcweir             Note: These values are used in combination. So they must be
83cdf0e10cSrcweir             values in form 2^n.
84cdf0e10cSrcweir          */
85cdf0e10cSrcweir         enum ERequest
86cdf0e10cSrcweir         {
87cdf0e10cSrcweir             /// mark a job URL as not valid
88cdf0e10cSrcweir             E_UNKNOWN = 0,
89cdf0e10cSrcweir             /// it's an event
90cdf0e10cSrcweir             E_EVENT   = 1,
91cdf0e10cSrcweir             /// it's an alias
92cdf0e10cSrcweir             E_ALIAS   = 2,
93cdf0e10cSrcweir             /// it's a service
94cdf0e10cSrcweir             E_SERVICE = 4
95cdf0e10cSrcweir         };
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     //___________________________________
98cdf0e10cSrcweir     // types
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     private:
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         /** knows the state of this URL instance */
103cdf0e10cSrcweir         sal_uInt32 m_eRequest;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         /** holds the event part of a job URL */
106cdf0e10cSrcweir         ::rtl::OUString m_sEvent;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         /** holds the alias part of a job URL */
109cdf0e10cSrcweir         ::rtl::OUString m_sAlias;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         /** holds the service part of a job URL */
112cdf0e10cSrcweir         ::rtl::OUString m_sService;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         /** holds the event arguments */
115cdf0e10cSrcweir         ::rtl::OUString m_sEventArgs;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         /** holds the alias arguments */
118cdf0e10cSrcweir         ::rtl::OUString m_sAliasArgs;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir         /** holds the service arguments */
121cdf0e10cSrcweir         ::rtl::OUString m_sServiceArgs;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     //___________________________________
124cdf0e10cSrcweir     // native interface
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     public:
127cdf0e10cSrcweir 
128cdf0e10cSrcweir                  JobURL        ( const ::rtl::OUString& sURL         );
129cdf0e10cSrcweir         sal_Bool isValid       (                                     ) const;
130cdf0e10cSrcweir         sal_Bool getEvent      (       ::rtl::OUString& sEvent       ) const;
131cdf0e10cSrcweir         sal_Bool getAlias      (       ::rtl::OUString& sAlias       ) const;
132cdf0e10cSrcweir         sal_Bool getService    (       ::rtl::OUString& sService     ) const;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     //___________________________________
135cdf0e10cSrcweir     // private helper
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     private:
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         static sal_Bool implst_split( const ::rtl::OUString& sPart           ,
140cdf0e10cSrcweir                                       const sal_Char*        pPartIdentifier ,
141cdf0e10cSrcweir                                             sal_Int32        nPartLength     ,
142cdf0e10cSrcweir                                             ::rtl::OUString& rPartValue      ,
143cdf0e10cSrcweir                                             ::rtl::OUString& rPartArguments  );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     //___________________________________
146cdf0e10cSrcweir     // debug methods!
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     #ifdef ENABLE_COMPONENT_SELF_CHECK
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     public:
151cdf0e10cSrcweir         static void impldbg_checkIt();
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     private:
154cdf0e10cSrcweir         static void impldbg_checkURL( const sal_Char*  pURL                 ,
155cdf0e10cSrcweir                                             sal_uInt32 eExpectedPart        ,
156cdf0e10cSrcweir                                       const sal_Char*  pExpectedEvent       ,
157cdf0e10cSrcweir                                       const sal_Char*  pExpectedAlias       ,
158cdf0e10cSrcweir                                       const sal_Char*  pExpectedService     ,
159cdf0e10cSrcweir                                       const sal_Char*  pExpectedEventArgs   ,
160cdf0e10cSrcweir                                       const sal_Char*  pExpectedAliasArgs   ,
161cdf0e10cSrcweir                                       const sal_Char*  pExpectedServiceArgs );
162cdf0e10cSrcweir         ::rtl::OUString impldbg_toString() const;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         sal_Bool getServiceArgs(       ::rtl::OUString& sServiceArgs ) const;
165cdf0e10cSrcweir         sal_Bool getEventArgs  (       ::rtl::OUString& sEventArgs   ) const;
166cdf0e10cSrcweir         sal_Bool getAliasArgs  (       ::rtl::OUString& sAliasArgs   ) const;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     #endif // ENABLE_COMPONENT_SELF_CHECK
169cdf0e10cSrcweir };
170cdf0e10cSrcweir 
171cdf0e10cSrcweir } // namespace framework
172cdf0e10cSrcweir 
173cdf0e10cSrcweir #endif // __FRAMEWORK_JOBS_JOBURL_HXX_
174