]> git.pld-linux.org Git - packages/libreoffice.git/blob - openoffice-vfs-uno-uri.patch
- up
[packages/libreoffice.git] / openoffice-vfs-uno-uri.patch
1 Index: tools/bootstrp/static.mk
2 ===================================================================
3 RCS file: /cvs/util/tools/bootstrp/static.mk,v
4 retrieving revision 1.26
5 diff -u -p -u -r1.26 static.mk
6 --- tools/bootstrp/static.mk    15 Apr 2003 17:55:11 -0000      1.26
7 +++ tools/bootstrp/static.mk    14 May 2003 08:02:07 -0000
8 @@ -146,6 +146,7 @@ STATIC_LIBS         +=      -lX11 -lXext 
9  .ELSE
10  STATIC_LIBS            +=      -lsupc++ -lX11 -lXext 
11  .ENDIF
12 +STATIC_LIBS             += `pkg-config --libs gnome-vfs-2.0`
13  .ENDIF
14  
15  # -----------------------------------------------------------
16 Index: tools/source/fsys/makefile.mk
17 ===================================================================
18 RCS file: /cvs/util/tools/source/fsys/makefile.mk,v
19 retrieving revision 1.7
20 diff -u -p -u -r1.7 makefile.mk
21 --- tools/source/fsys/makefile.mk       30 Apr 2003 08:25:46 -0000      1.7
22 +++ tools/source/fsys/makefile.mk       14 May 2003 08:02:07 -0000
23 @@ -101,6 +101,8 @@ OBJFILES=   $(OBJ)$/wldcrd.obj   \
24              $(OBJ)$/tdir.obj   \
25              $(OBJ)$/urlobj.obj
26  
27 +CFLAGS+=`pkg-config --cflags gnome-vfs-2.0`
28 +
29  # --- Targets ------------------------------------------------------
30  
31  .INCLUDE :  target.mk
32 Index: tools/source/fsys/urlobj.cxx
33 ===================================================================
34 RCS file: /cvs/util/tools/source/fsys/urlobj.cxx,v
35 retrieving revision 1.37
36 diff -u -p -u -r1.37 urlobj.cxx
37 --- tools/source/fsys/urlobj.cxx        24 Apr 2003 13:27:52 -0000      1.37
38 +++ tools/source/fsys/urlobj.cxx        14 May 2003 08:02:10 -0000
39 @@ -107,6 +107,43 @@
40  #define INCLUDED_LIMITS
41  #endif
42  
43 +#ifndef _VOS_MUTEX_HXX
44 +#include <vos/mutex.hxx>
45 +#endif
46 +
47 +#include <stdio.h>
48 +#include <signal.h>
49 +
50 +#include <libgnomevfs/gnome-vfs.h>
51 +
52 +#undef USE_GNOME_VFS_2_2
53 +
54 +#ifdef USE_GNOME_VFS_2_2
55 +extern "C" {
56 +  GList *_gnome_vfs_configuration_get_methods_list (void);
57 +}
58 +#endif
59 +
60 +static GList *
61 +get_methods_list (void)
62 +{
63 +#ifdef USE_GNOME_VFS_2_2
64 +  return _gnome_vfs_configuration_get_methods_list ();
65 +#else
66 +  /* This sucks utterly */
67 +  const char *methods[] = {
68 +    "smb", "pipe", "ssh", "nntp", "gnome-help", "preferences", "ncp",
69 +    "applications", "favorites", "cdda", "system", "nfs", "camera"
70 +// "mailfs", "hp8", "patchfs" - broken extfs stuff ...
71 +  };
72 +  int i;
73 +  GList *ret = NULL;
74 +  for (i = 0; i < G_N_ELEMENTS (methods); i++)
75 +    ret = g_list_prepend (ret, (void *) methods [i]);
76 +  return ret;
77 +#endif
78 +}
79 +
80  namespace unnamed_tools_urlobj {} using namespace unnamed_tools_urlobj;
81         // unnamed namespaces don't work well yet...
82  
83 @@ -393,6 +430,8 @@ struct INetURLObject::PrefixInfo
84  };
85  
86  //============================================================================
87 +static INetURLObject::SchemeInfo *vfs_schemeinfo_map = NULL;
88 +
89  static INetURLObject::SchemeInfo const aSchemeInfoMap[INET_PROT_END]
90         = { { "", "", 0, false, false, false, false, false, false, false,
91                   false },
92 @@ -459,7 +498,10 @@ static INetURLObject::SchemeInfo const a
93  inline INetURLObject::SchemeInfo const &
94  INetURLObject::getSchemeInfo(INetProtocol eTheScheme)
95  {
96 -       return aSchemeInfoMap[eTheScheme];
97 +   if (eTheScheme >= INET_PROT_END)
98 +     return vfs_schemeinfo_map [eTheScheme - INET_PROT_END];
99 +   else
100 +     return aSchemeInfoMap[eTheScheme];
101  };
102  
103  //============================================================================
104 @@ -720,15 +762,21 @@ bool INetURLObject::setAbsURIRef(UniStri
105         // Parse <scheme>:
106         sal_Unicode const * p = pPos;
107         PrefixInfo const * pPrefix = getPrefix(p, pEnd);
108 +       ::rtl::OString tmpStr (rTheAbsURIRef.GetBuffer (),
109 +                              rTheAbsURIRef.Len (),
110 +                              RTL_TEXTENCODING_UTF8);
111 +
112 +       //      fprintf (stderr, "setAbsURIRef '%s' %d\n", tmpStr.getStr(),
113 +       //               (int) (pPrefix ? pPrefix->m_eScheme : -17));
114         if (pPrefix)
115         {
116                 pPos = p;
117                 m_eScheme = pPrefix->m_eScheme;
118                 aSynAbsURIRef
119                         = UniString::CreateFromAscii(pPrefix->m_eKind
120 -                                                                                        >= PrefixInfo::EXTERNAL ?
121 -                                                                                    pPrefix->m_pTranslatedPrefix :
122 -                                                                                    pPrefix->m_pPrefix);
123 +                                                    >= PrefixInfo::EXTERNAL ?
124 +                                                    pPrefix->m_pTranslatedPrefix :
125 +                                                    pPrefix->m_pPrefix);
126         }
127         else
128         {
129 @@ -871,6 +919,8 @@ bool INetURLObject::setAbsURIRef(UniStri
130                 sal_Unicode const * pHostPortBegin = 0;
131                 sal_Unicode const * pHostPortEnd = 0;
132  
133 +//             fprintf (stderr, "Got Authority\n");
134 +
135                 switch (m_eScheme)
136                 {
137                         case INET_PROT_VND_SUN_STAR_HELP:
138 @@ -1170,6 +1220,7 @@ bool INetURLObject::setAbsURIRef(UniStri
139                           && !(m_eScheme == INET_PROT_FILE
140                                && pPos != pEnd && *pPos == '/'))
141                                 {
142 +//                       fprintf (stderr, "not smart\n");
143                                         setInvalid();
144                                         return false;
145                                 }
146 @@ -1211,6 +1262,7 @@ bool INetURLObject::setAbsURIRef(UniStri
147                                 }
148                                 else if (pPos != pAuthority)
149                                 {
150 +//                       fprintf (stderr, "bogus auth\n");
151                                         setInvalid();
152                                         return false;
153                                 }
154 @@ -1290,6 +1342,7 @@ bool INetURLObject::setAbsURIRef(UniStri
155                                                                                                          eEscapeType);
156                                                 if (!INetMIME::isIMAPAtomChar(nUTF32))
157                                                 {
158 +//                       fprintf (stderr, "bogus char\n");
159                                                         setInvalid();
160                                                         return false;
161                                                 }
162 @@ -1329,14 +1382,17 @@ bool INetURLObject::setAbsURIRef(UniStri
163                                 case INET_PROT_LDAP:
164                                         if (pHostPortBegin == pPort && pPort != pHostPortEnd)
165                                         {
166 +//                       fprintf (stderr, "bogus port 0\n");
167                                                 setInvalid();
168                                                 return false;
169                                         }
170                                         break;
171  
172                                 default:
173 -                                       if (pHostPortBegin == pPort)
174 +                                       if (m_eScheme < INET_PROT_END && /* else might have a port */
175 +                                           pHostPortBegin == pPort)
176                                         {
177 +//                       fprintf (stderr, "bogus port\n");
178                                                 setInvalid();
179                                                 return false;
180                                         }
181 @@ -1346,6 +1402,7 @@ bool INetURLObject::setAbsURIRef(UniStri
182                         if (!parseHost(pHostPortBegin, pPort, bOctets, eMechanism, eCharset,
183                             bNetBiosName, &aSynHost))
184                         {
185 +//                       fprintf (stderr, "bogus host\n");
186                                 setInvalid();
187                                 return false;
188                         }
189 @@ -1360,6 +1417,10 @@ bool INetURLObject::setAbsURIRef(UniStri
190                 }
191         }
192  
193 +//     ::rtl::OString tmpStrPP (pPos, pEnd - pPos,
194 +//                              RTL_TEXTENCODING_UTF8);
195 +//     fprintf (stderr, "Pre path parse '%s'\n", tmpStrPP.getStr());
196 +
197         // Parse <path>
198         UniString aSynPath;
199         if (!parsePath(m_eScheme, &pPos, pEnd, bOctets, eMechanism, eCharset,
200 @@ -1368,6 +1429,7 @@ bool INetURLObject::setAbsURIRef(UniStri
201                                    getSchemeInfo().m_bQuery ? '?' : 0x80000000,
202                                    nFragmentDelimiter, &aSynPath))
203         {
204 +//       fprintf (stderr, "Invalid path\n");
205                 setInvalid();
206                 return false;
207         }
208 @@ -1407,12 +1469,20 @@ bool INetURLObject::setAbsURIRef(UniStri
209  
210         if (pPos != pEnd)
211         {
212 +//       ::rtl::OString tmpStrZ (pPos, pEnd - pPos,
213 +//                              RTL_TEXTENCODING_UTF8);
214 +//       fprintf (stderr, "Invalid fragment '%s'\n", tmpStrZ.getStr());
215                 setInvalid();
216                 return false;
217         }
218  
219         m_aAbsURIRef = aSynAbsURIRef;
220  
221 +//     ::rtl::OString tmpStr2 (aSynAbsURIRef.GetBuffer (),
222 +//                             aSynAbsURIRef.Len (),
223 +//                             RTL_TEXTENCODING_UTF8);
224 +//     fprintf (stderr, "setAbsURIRef result '%s'\n", tmpStr2.getStr());
225 +
226         return true;
227  }
228  
229 @@ -1422,13 +1492,13 @@ INetURLObject INetURLObject::m_aBaseURIR
230  
231  //============================================================================
232  bool INetURLObject::convertRelToAbs(UniString const & rTheRelURIRef,
233 -                                                                       bool bOctets,
234 -                                                                       INetURLObject & rTheAbsURIRef,
235 -                                                                       bool & rWasAbsolute,
236 -                                                                       EncodeMechanism eMechanism,
237 -                                                                       rtl_TextEncoding eCharset,
238 -                                                                       bool bIgnoreFragment, bool bSmart,
239 -                                                                       bool bRelativeNonURIs, FSysStyle eStyle)
240 +                                   bool bOctets,
241 +                                   INetURLObject & rTheAbsURIRef,
242 +                                   bool & rWasAbsolute,
243 +                                   EncodeMechanism eMechanism,
244 +                                   rtl_TextEncoding eCharset,
245 +                                   bool bIgnoreFragment, bool bSmart,
246 +                                   bool bRelativeNonURIs, FSysStyle eStyle)
247         const
248  {
249         sal_Unicode const * p = rTheRelURIRef.GetBuffer();
250 @@ -1443,6 +1513,11 @@ bool INetURLObject::convertRelToAbs(UniS
251         sal_uInt32 nFragmentDelimiter = '#';
252         Part ePart = PART_VISIBLE;
253  
254 +//     if (pPrefix)
255 +//       fprintf (stderr, "Got pPrefix\n");
256 +//     else
257 +//       fprintf (stderr, "No pPrefix\n");
258 +
259         if (!pPrefix && bSmart)
260         {
261                 // If the input matches any of the following productions (for which
262 @@ -1545,9 +1620,12 @@ bool INetURLObject::convertRelToAbs(UniS
263         // Fast solution for non-relative URIs:
264         if (pPrefix)
265         {
266 +//             fprintf (stderr, "Fast pPrefix path\n");
267 +
268                 INetURLObject aNewURI(rTheRelURIRef, eMechanism, eCharset);
269                 if (aNewURI.HasError())
270                 {
271 +//               fprintf (stderr, "Had error!\n");
272                         rWasAbsolute = false;
273                         return false;
274                 }
275 @@ -1555,14 +1633,22 @@ bool INetURLObject::convertRelToAbs(UniS
276                 if (bIgnoreFragment)
277                         aNewURI.clearFragment();
278                 rTheAbsURIRef = aNewURI;
279 +
280 +//             ::rtl::OString tmpStr2 (m_aAbsURIRef.GetBuffer (),
281 +//                                     m_aAbsURIRef.Len (),
282 +//                                     RTL_TEXTENCODING_UTF8);
283 +//             fprintf (stderr, "Hard set to '%s' \n", tmpStr2.getStr());
284 +
285                 return true;
286         }
287  
288 +//     fprintf (stderr, "Slow non pPrefix path\n");
289 +
290         enum State { STATE_AUTH, STATE_ABS_PATH, STATE_REL_PATH, STATE_FRAGMENT,
291                                  STATE_DONE };
292  
293         UniString aSynAbsURIRef(UniString::CreateFromAscii(getSchemeInfo().
294 -                                                                                                              m_pScheme));
295 +                                                          m_pScheme));
296         aSynAbsURIRef += ':';
297  
298         sal_Char cEscapePrefix = getEscapePrefix();
299 @@ -2082,13 +2168,95 @@ INetURLObject::getPrefix(sal_Unicode con
300                         { "vnd.sun.star.wfs:", 0, INET_PROT_VND_SUN_STAR_WFS,
301                           PrefixInfo::OFFICIAL },
302                         { "wfs:", "vnd.sun.star.wfs:", INET_PROT_VND_SUN_STAR_WFS,
303 -                         PrefixInfo::ALIAS } };
304 -       PrefixInfo const * pFirst = aMap + 1;
305 -       PrefixInfo const * pLast = aMap + sizeof aMap / sizeof (PrefixInfo) - 1;
306 -       PrefixInfo const * pMatch = 0;
307 -       sal_Unicode const * pMatched = rBegin;
308 -       sal_Unicode const * p = rBegin;
309 -       xub_StrLen i = 0;
310 +                         PrefixInfo::ALIAS }
311 +               };
312 +
313 +       static GHashTable *fast_lookup = NULL;
314 +       int i;
315 +
316 +       if (!fast_lookup) {
317 +               ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
318 +               if (!fast_lookup) {
319 +                       // FIXME: This code should be re-factored, but C++ is
320 +                       // broken by design for re-factoring.
321 +                       GList *methods, *l;
322 +
323 +                       fast_lookup = g_hash_table_new (g_str_hash, g_str_equal);
324 +         
325 +                       for (i = 1; i < G_N_ELEMENTS (aMap); i++) {
326 +                               g_hash_table_insert (fast_lookup, (void *) aMap[i].m_pPrefix,
327 +                                                    (void *) (aMap + i));
328 +                       }
329 +
330 +                       methods = get_methods_list ();
331 +                       vfs_schemeinfo_map = g_new0 (INetURLObject::SchemeInfo, g_list_length (methods));
332 +
333 +                       i = INET_PROT_END;
334 +                       for (l = methods; l; l = l->next) {
335 +                               PrefixInfo *pi;
336 +                               INetURLObject::SchemeInfo *si;
337 +                               char *name;
338 +
339 +                               name = g_strconcat ((gchar *) l->data, ":", NULL);
340 +
341 +                               //          g_warning ("AddV '%s'", name);
342 +                               if (g_hash_table_lookup (fast_lookup, name)) {
343 +                                       fprintf (stderr, "Discarding URI scheme '%s'", name);
344 +                                       g_free (name);
345 +                                       continue;
346 +                               }
347 +
348 +                               pi = new PrefixInfo;
349 +
350 +                               pi->m_pPrefix = (sal_Char *) name;
351 +                               pi->m_pTranslatedPrefix = NULL;
352 +                               pi->m_eScheme = (INetProtocol) i;
353 +                               pi->m_eKind = PrefixInfo::OFFICIAL;
354 +
355 +                               si = &vfs_schemeinfo_map [i - INET_PROT_END];
356 +
357 +                               si->m_pScheme = (sal_Char *) l->data;
358 +                               si->m_pPrefix = g_strconcat (name, "//", NULL); // what a waste
359 +
360 +                               // FIXME: these are just wrong, set all to true ?
361 +                               si->m_nDefaultPort = 0;
362 +                               si->m_bAuthority = true;
363 +                               si->m_bUser = false;
364 +                               si->m_bAuth = false;
365 +                               si->m_bPassword = false;
366 +                               si->m_bHost = true;
367 +                               si->m_bPort = false;
368 +                               si->m_bHierarchical = true;
369 +                               si->m_bQuery = false;
370 +
371 +                               g_hash_table_insert (fast_lookup, (void *) pi->m_pPrefix, (void *) pi);
372 +                               i++;
373 +                       }
374 +               }
375 +
376 +               // FIXME: add write barrier when this reaches OOO_STABLE_1
377 +       }
378 +
379 +       char *rstr;
380 +
381 +       rstr = (char *) g_alloca (pEnd - rBegin + 2);
382 +       for (i = 0; i < pEnd - rBegin && rBegin [i] != ':'; i++)
383 +         rstr[i] = INetMIME::toLowerCase (rBegin [i]);
384 +       if (i >= pEnd - rBegin) return NULL;
385 +       rstr [i++] = ':'; rstr [i] = '\0';
386 +
387 +       const PrefixInfo *pi;
388 +
389 +       pi = (PrefixInfo *) g_hash_table_lookup (fast_lookup, rstr);
390 +
391 +//     g_warning ("Lookup '%s' -> %d", rstr, (int) (pi ? pi->m_eScheme : -17));
392 +
393 +       if (pi)
394 +         rBegin += i;
395 +
396 +       return pi;
397 +
398 +#ifdef OVER_COMPLICATED_CODE
399         for (; pFirst < pLast; ++i)
400         {
401                 if (pFirst->m_pPrefix[i] == '\0')
402 @@ -2120,7 +2288,9 @@ INetURLObject::getPrefix(sal_Unicode con
403                 }
404         }
405         rBegin = pMatched;
406 +
407         return pMatch;
408 +#endif
409  }
410  
411  //============================================================================
412 @@ -2359,7 +2529,7 @@ bool INetURLObject::setHost(UniString co
413                         break;
414  
415                 default:
416 -                       if (aSynHost.Len() == 0)
417 +                       if (aSynHost.Len() == 0 && m_eScheme < INET_PROT_END)
418                                 return false;
419                         break;
420         }
421 @@ -2436,6 +2606,7 @@ bool INetURLObject::parsePath(INetProtoc
422                                 aTheSynPath = '/';
423                         break;
424  
425 +               default: /* All INET_PROT_END+ drop through here */
426                 case INET_PROT_FILE:
427                 case INET_PROT_VND_SUN_STAR_WFS:
428                 {
429 @@ -3618,7 +3789,8 @@ bool INetURLObject::ConcatData(INetProto
430                                         break;
431  
432                                 default:
433 -                                       if (aSynHost.Len() == 0)
434 +                                       if (aSynHost.Len() == 0 &&
435 +                                           m_eScheme < INET_PROT_END) /* valid perhaps */
436                                         {
437                                                 setInvalid();
438                                                 return false;
439 Index: tools/util/makefile.mk
440 ===================================================================
441 RCS file: /cvs/util/tools/util/makefile.mk,v
442 retrieving revision 1.10
443 diff -u -p -u -r1.10 makefile.mk
444 --- tools/util/makefile.mk      30 Apr 2003 08:25:57 -0000      1.10
445 +++ tools/util/makefile.mk      14 May 2003 08:02:10 -0000
446 @@ -200,6 +200,10 @@ SHL1STDLIBS+=   shell32.lib     \
447                  uuid.lib        \
448                  advapi32.lib
449  .ENDIF
450 +.IF "$(GUI)"=="UNX"
451 +SHL1STDLIBS+=`pkg-config --libs gnome-vfs-2.0`
452 +.ENDIF
453 +
454  
455  DEF1NAME        =$(SHL1TARGET)
456  DEF1DEPN = \
This page took 0.0934 seconds and 3 git commands to generate.