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