summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-15 22:19:08 (UTC)
committer zecke <zecke>2002-09-15 22:19:08 (UTC)
commitaabe567e96d040c483b947f5758a1405cc312fdc (patch) (unidiff)
treeceb8ebba2384f1737277c0dfb89256eaa2ac1717
parent09561ee29b5288e02e513172fc590d27e9e09333 (diff)
downloadopie-aabe567e96d040c483b947f5758a1405cc312fdc.zip
opie-aabe567e96d040c483b947f5758a1405cc312fdc.tar.gz
opie-aabe567e96d040c483b947f5758a1405cc312fdc.tar.bz2
add files
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/olister.cpp72
-rw-r--r--libopie/ofileselector/olister.cpp~64
-rw-r--r--libopie/ofileselector/olister.h59
-rw-r--r--libopie/ofileselector/olister.h~57
-rw-r--r--libopie/ofileselector/olister.obin0 -> 24852 bytes
-rw-r--r--libopie/ofileselector/olocallister.cpp118
-rw-r--r--libopie/ofileselector/olocallister.cpp~97
-rw-r--r--libopie/ofileselector/olocallister.h14
-rw-r--r--libopie/ofileselector/olocallister.h~14
-rw-r--r--libopie/ofileselector/olocallister.obin0 -> 42280 bytes
10 files changed, 495 insertions, 0 deletions
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp
new file mode 100644
index 0000000..6c43043
--- a/dev/null
+++ b/libopie/ofileselector/olister.cpp
@@ -0,0 +1,72 @@
1#include "olister.h"
2#include "ofileview.h"
3#include "ofileselector.h"
4
5
6OLister::OLister( OFileSelector* view)
7 : m_view( view )
8{
9}
10OLister::~OLister() {
11}
12bool OLister::showFiles()const {
13 return m_view->showFiles();
14}
15bool OLister::showDirs()const {
16 return m_view->showDirs();
17}
18void OLister::addFile( const QString& mine,
19 QFileInfo* info,
20 bool isSymlink ) {
21 view()->currentView()->addFile( mine,
22 info,
23 isSymlink );
24}
25void OLister::addFile( const QString& mine,
26 const QString& path,
27 const QString& file,
28 bool isSymlink ) {
29 view()->currentView()->addFile( mine,
30 path,
31 file,
32 isSymlink );
33}
34void OLister::addDir( const QString& mine,
35 QFileInfo* info,
36 bool isSymlink ) {
37
38 view()->currentView()->addDir( mine,
39 info,
40 isSymlink );
41}
42void OLister::addDir( const QString& mine,
43 const QString& path,
44 const QString& dir,
45 bool isSymlink ) {
46 view()->currentView()->addDir( mine,
47 path,
48 dir,
49 isSymlink );
50}
51void OLister::addSymlink( const QString& mine,
52 QFileInfo* info,
53 bool isSymlink ) {
54 view()->currentView()->addSymlink( mine,
55 info,
56 isSymlink );
57}
58void OLister::addSymlink( const QString& mine,
59 const QString& path,
60 const QString& name,
61 bool isSymlink ) {
62 view()->currentView()->addSymlink( mine,
63 path,
64 name,
65 isSymlink );
66}
67OFileSelector* OLister::view() {
68 return m_view;
69}
70bool OLister::compliesMime( const QString& mime ) {
71 return view()->compliesMime( mime );
72}
diff --git a/libopie/ofileselector/olister.cpp~ b/libopie/ofileselector/olister.cpp~
new file mode 100644
index 0000000..180422a
--- a/dev/null
+++ b/libopie/ofileselector/olister.cpp~
@@ -0,0 +1,64 @@
1#include "olister.h"
2#include "ofileview.h"
3#include "ofileselector.h"
4
5
6OLister::OLister( OFileSelector* view)
7 : m_view( view )
8{
9}
10OLister::~OLister() {
11}
12void OLister::addFile( const QString& mine,
13 QFileInfo* info,
14 bool isSymlink ) {
15 view()->currentView()->addFile( mine,
16 info,
17 isSymlink );
18}
19void OLister::addFile( const QString& mine,
20 const QString& path,
21 const QString& file,
22 bool isSymlink ) {
23 view()->currentView()->addFile( mine,
24 path,
25 file,
26 isSymlink );
27}
28void OLister::addDir( const QString& mine,
29 QFileInfo* info,
30 bool isSymlink ) {
31
32 view()->currentView()->addDir( mine,
33 info,
34 isSymlink );
35}
36void OLister::addDir( const QString& mine,
37 const QString& path,
38 const QString& dir,
39 bool isSymlink ) {
40 view()->currentView()->addDir( mine,
41 path,
42 dir,
43 isSymlink );
44}
45void OLister::addSymlink( const QString& mine,
46 QFileInfo* info,
47 bool isSymlink ) {
48 view()->currentView()->addSymlink( mine,
49 info,
50 isSymlink );
51}
52void OLister::addSymlink( const QString& mine,
53 const QString& path,
54 const QString& name,
55 bool isSymlink ) {
56 view()->currentView()->addSymlink( mine,
57 path,
58 name,
59 isSymlink );
60}
61OFileSelector* OLister::view() {
62 return m_view;
63}
64
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h
new file mode 100644
index 0000000..081b876
--- a/dev/null
+++ b/libopie/ofileselector/olister.h
@@ -0,0 +1,59 @@
1#ifndef OPIE_FILE_LISTER_H
2#define OPIE_FILE_LISTER_H
3
4#include <qfileinfo.h>
5#include <qmap.h>
6#include <qstring.h>
7
8class OFileSelector;
9/**
10 * lister is something like KIO but very
11 * very basic and currently only for
12 * populating our views.
13 * This is a base class which needs to be implemented.
14 * @see OLocalLister for a filesystem based implementation
15 */
16class OLister {
17public:
18 OLister( OFileSelector* );
19 virtual ~OLister();
20 virtual void reparse(const QString& path) = 0;
21
22 /**
23 * return a list of available mimetypes
24 */
25 virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0;
26
27protected:
28 bool showFiles()const;
29 bool showDirs()const;
30 bool compliesMime( const QString& mime );
31 void addFile( const QString& mine,
32 QFileInfo*,
33 bool isSymlink = FALSE );
34 void addFile( const QString& mine,
35 const QString& path,
36 const QString& file,
37 bool isSymlink = FALSE );
38 void addDir( const QString& mine,
39 QFileInfo*,
40 bool isSymlink = FALSE );
41 void addDir( const QString& mine,
42 const QString& path,
43 const QString& dir,
44 bool isSymlink = FALSE );
45 void addSymlink( const QString& mine,
46 QFileInfo* info,
47 bool isSymlink = FALSE);
48 void addSymlink( const QString& mine,
49 const QString& path,
50 const QString& name,
51 bool isSymlink = FALSE );
52 OFileSelector* view();
53private:
54 OFileSelector* m_view;
55
56
57};
58
59#endif
diff --git a/libopie/ofileselector/olister.h~ b/libopie/ofileselector/olister.h~
new file mode 100644
index 0000000..bb6304c
--- a/dev/null
+++ b/libopie/ofileselector/olister.h~
@@ -0,0 +1,57 @@
1#ifndef OPIE_FILE_LISTER_H
2#define OPIE_FILE_LISTER_H
3
4#include <qfileinfo.h>
5#include <qmap.h>
6#include <qstring.h>
7
8class OFileSelector;
9/**
10 * lister is something like KIO but very
11 * very basic and currently only for
12 * populating our views.
13 * This is a base class which needs to be implemented.
14 * @see OLocalLister for a filesystem based implementation
15 */
16class OLister {
17public:
18 OLister( OFileSelector* );
19 virtual ~OLister();
20 virtual void reparse(const QString& path) = 0;
21
22 /**
23 * return a list of available mimetypes
24 */
25 virtual QMap<QString, QString> mimeTypes( const QString& dir ) = 0;
26
27protected:
28
29 void addFile( const QString& mine,
30 QFileInfo*,
31 bool isSymlink = FALSE );
32 void addFile( const QString& mine,
33 const QString& path,
34 const QString& file,
35 bool isSymlink = FALSE );
36 void addDir( const QString& mine,
37 QFileInfo*,
38 bool isSymlink = FALSE );
39 void addDir( const QString& mine,
40 const QString& path,
41 const QString& dir,
42 bool isSymlink = FALSE );
43 void addSymlink( const QString& mine,
44 QFileInfo* info,
45 bool isSymlink = FALSE);
46 void addSymlink( const QString& mine,
47 const QString& path,
48 const QString& name,
49 bool isSymlink = FALSE );
50 OFileSelector* view();
51private:
52 OFileSelector* m_view;
53
54
55};
56
57#endif
diff --git a/libopie/ofileselector/olister.o b/libopie/ofileselector/olister.o
new file mode 100644
index 0000000..ca58d6c
--- a/dev/null
+++ b/libopie/ofileselector/olister.o
Binary files differ
diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp
new file mode 100644
index 0000000..6ffcf1e
--- a/dev/null
+++ b/libopie/ofileselector/olocallister.cpp
@@ -0,0 +1,118 @@
1#include <qdir.h>
2#include <qfileinfo.h>
3#include <qmap.h>
4
5#include <qpe/mimetype.h>
6
7#include "ofileselector.h"
8#include "olocallister.h"
9
10OLocalLister::OLocalLister( OFileSelector* file )
11 : OLister( file )
12{
13}
14OLocalLister::~OLocalLister() {
15}
16
17QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) {
18 QMap<QString, QStringList> mimes;
19
20 // let's find possible mimetypes
21 QDir dir( curDir );
22 dir.setFilter( QDir::Files | QDir::Readable );
23 dir.setSorting( QDir::Size );
24
25 const QFileInfoList *list = dir.entryInfoList();
26 QFileInfoListIterator it( *list );
27 QFileInfo *fi;
28
29 while( (fi=it.current() ) ) {
30 /* skip .desktop */
31 if( fi->extension() == QString::fromLatin1("desktop") ){
32 ++it;
33 continue;
34 }
35 MimeType type( fi->absFilePath() );
36
37 if( !mimes.contains( type.id() ) ){
38 mimes.insert( type.id(), type.id() );
39 }
40
41 ++it;
42 }
43
44 return mimes;
45}
46/* FIXME mimecheck
47 * use mime check for that
48 * filter dirs
49 * filter filters
50 * filter files
51 * filter mimetypes
52 */
53void OLocalLister::reparse( const QString& path ) {
54 QString currentMimeType;
55 QDir dir( path );
56
57 dir.setSorting( view()->sorting() );
58 dir.setFilter( view()->filter() );
59
60
61 const QFileInfoList *list = dir.entryInfoList();
62 QFileInfoListIterator it( *list );
63 QFileInfo *fi;
64
65 while( (fi=it.current() ) ){
66
67 if( fi->fileName() == QString::fromLatin1("..") ||
68 fi->fileName() == QString::fromLatin1(".") ){
69 ++it;
70 continue;
71 }
72 if( fi->isSymLink() ){
73 QString file = fi->dirPath( true ) + "/" + fi->readLink();
74 /*
75 * 5 tries to prevent dos attack
76 */
77 for( int i = 0; i<=4; i++) {
78 QFileInfo info( file );
79 if( !info.exists() ){
80 addSymlink( currentMimeType, fi, TRUE );
81 break;
82 }else if( info.isDir() ){
83 if (!showDirs() )
84 break;
85
86 addDir( currentMimeType, fi,
87 TRUE );
88 break;
89 }else if( info.isFile() ){
90 /* if not show files skip it */
91 if (!showFiles() )
92 break;
93
94 /* check if we comply to the mimetype */
95 MimeType type( info.absFilePath() );
96 if (compliesMime( type.id() ) )
97 addFile( currentMimeType, fi, TRUE );
98
99 break;
100 }else if( info.isSymLink() ){
101 file = info.dirPath(true ) + "/" + info.readLink() ;
102 break;
103 }else if( i == 4){
104 addSymlink( currentMimeType, fi );
105 }
106 }
107
108 }else if( fi->isDir() ){
109 if (showDirs() )
110 addDir( currentMimeType, fi );
111 }else if( fi->isFile() ){
112 if ( showFiles() )
113 addFile( currentMimeType, fi );
114 }
115 ++it;
116 } // of while loop
117}
118
diff --git a/libopie/ofileselector/olocallister.cpp~ b/libopie/ofileselector/olocallister.cpp~
new file mode 100644
index 0000000..b0e5410
--- a/dev/null
+++ b/libopie/ofileselector/olocallister.cpp~
@@ -0,0 +1,97 @@
1#include <qdir.h>
2#include <qfileinfo.h>
3#include <qmap.h>
4
5#include <qpe/mimetype.h>
6
7#include "ofileselector.h"
8#include "olocallister.h"
9
10OLocalLister::OLocalLister( OFileSelector* file )
11 : OLister( file )
12{
13}
14OLocalLister::~OLocalLister() {
15}
16
17QMap<QString, QString> OLocalLister::mimeTypes( const QString& curDir ) {
18 QMap<QString, QString> mimes;
19
20 // let's find possible mimetypes
21 QDir dir( curDir );
22 dir.setFilter( QDir::Files | QDir::Readable );
23 dir.setSorting( QDir::Size );
24
25 const QFileInfoList *list = dir.entryInfoList();
26 QFileInfoListIterator it( *list );
27 QFileInfo *fi;
28
29 while( (fi=it.current() ) ) {
30 if( fi->extension() == QString::fromLatin1("desktop") ){
31 ++it;
32 continue;
33 }
34 MimeType type( fi->absFilePath() );
35
36 if( !mimes.contains( type.id() ) ){
37 mimes.insert( type.id(), type.id() );
38 }
39
40 ++it;
41 }
42
43 return mimes;
44}
45void OLocalLister::reparse( const QString& path ) {
46 QString currentMimeType;
47 QDir dir( path );
48
49 dir.setSorting( view()->sorting() );
50 dir.setFilter( view()->filter() );
51
52 // now go through all files
53 const QFileInfoList *list = dir.entryInfoList();
54 QFileInfoListIterator it( *list );
55 QFileInfo *fi;
56
57 while( (fi=it.current() ) ){
58
59 if( fi->fileName() == QString::fromLatin1("..") ||
60 fi->fileName() == QString::fromLatin1(".") ){
61 ++it;
62 continue;
63 }
64 if( fi->isSymLink() ){
65 QString file = fi->dirPath( true ) + "/" + fi->readLink();
66 /*
67 * 5 tries to prevent dos attack
68 */
69 for( int i = 0; i<=4; i++) {
70 QFileInfo info( file );
71 if( !info.exists() ){
72 addSymlink( currentMimeType, fi, TRUE );
73 break;
74 }else if( info.isDir() ){
75 addDir( currentMimeType, fi,
76 TRUE );
77 break;
78 }else if( info.isFile() ){
79 addFile( currentMimeType, fi, TRUE );
80 break;
81 }else if( info.isSymLink() ){
82 file = info.dirPath(true ) + "/" + info.readLink() ;
83 break;
84 }else if( i == 4){
85 addSymlink( currentMimeType, fi );
86 }
87 }
88
89 }else if( fi->isDir() ){
90 addDir( currentMimeType, fi );
91 }else if( fi->isFile() ){
92 addFile( currentMimeType, fi );
93 }
94 ++it;
95 } // of while loop
96}
97
diff --git a/libopie/ofileselector/olocallister.h b/libopie/ofileselector/olocallister.h
new file mode 100644
index 0000000..0a06102
--- a/dev/null
+++ b/libopie/ofileselector/olocallister.h
@@ -0,0 +1,14 @@
1#ifndef OPIE_LOCAL_LISTER
2#define OPIE_LOCAL_LISTER
3
4#include "olister.h"
5
6class OLocalLister : public OLister {
7public:
8 OLocalLister( OFileSelector* );
9 ~OLocalLister();
10 void reparse( const QString& path );
11 QMap<QString, QStringList> mimeTypes(const QString& dir );
12};
13
14#endif
diff --git a/libopie/ofileselector/olocallister.h~ b/libopie/ofileselector/olocallister.h~
new file mode 100644
index 0000000..a284b6e
--- a/dev/null
+++ b/libopie/ofileselector/olocallister.h~
@@ -0,0 +1,14 @@
1#ifndef OPIE_LOCAL_LISTER
2#define OPIE_LOCAL_LISTER
3
4#include "olister.h"
5
6class OLocalLister : public OLister {
7public:
8 OLocalLister( OFileSelector* );
9 ~OLocalLister();
10 void reparse( const QString& path );
11 QMap<QString, QString> mimeTypes(const QString& dir );
12};
13
14#endif
diff --git a/libopie/ofileselector/olocallister.o b/libopie/ofileselector/olocallister.o
new file mode 100644
index 0000000..1a4685d
--- a/dev/null
+++ b/libopie/ofileselector/olocallister.o
Binary files differ