21 #include <tqstringlist.h>
23 void urlToSmb(
const KURL& url, TQString& work, TQString& server, TQString& printer)
25 if (url.protocol() !=
"smb")
27 TQString h = url.host();
28 TQStringList l = TQStringList::split(
'/', url.path(),
false);
37 work = TQString::null;
43 KURL smbToUrl(
const TQString& s)
52 url = KURL(
"smb://" + KURL::encode_string(s.mid(6)));
57 TQString username = s.mid(6, p-6);
58 url = KURL(
"smb://" + KURL::encode_string(s.mid(p+1)));
59 int q = username.find(
':');
61 url.setUser(username);
64 url.setUser(username.left(q));
65 url.setPass(username.mid(q+1));
73 for (
int i=0; i<KPrinter::NPageSize-1; i++)
74 if (page_sizes[i].ID == ID)
79 TQString buildSmbURI(
const TQString& work,
const TQString& server,
const TQString& printer,
const TQString& user,
const TQString& passwd )
81 TQString uri = server +
"/" + printer;
82 if ( !work.isEmpty() )
83 uri.prepend( work +
"/" );
84 if ( !user.isEmpty() )
87 if ( !passwd.isEmpty() )
88 uri.prepend(
":" + passwd );
91 uri.prepend(
"smb://" );
95 bool splitSmbURI(
const TQString& uri, TQString& work, TQString& server, TQString& printer, TQString& user, TQString& passwd )
98 if ( !uri.startsWith(
"smb://" ) )
102 int p1 = uri.find(
'/', p );
105 int p2 = uri.find(
'@', p );
106 if ( p2 != -1 && p2 < p1 )
109 int p3 = uri.find(
':', p );
110 if ( p3 != -1 && p3 < p2 )
113 user = uri.mid( p, p3-p );
114 passwd = uri.mid( p3+1, p2-p3-1 );
117 user = uri.mid( p, p2-p );
121 TQStringList l = TQStringList::split(
'/', uri.mid( p2+1 ),
false );