Skip to content

Commit b94688d

Browse files
committed
initial
1 parent 2024151 commit b94688d

13 files changed

+2191
-0
lines changed

Makefile

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
#############################################################################
2+
# Makefile for building: qcryptdisk
3+
# Generated by qmake (2.01a) (Qt 4.8.2) on: ?? ???. 10 19:09:31 2012
4+
# Project: qcryptdisk.pro
5+
# Template: app
6+
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile qcryptdisk.pro
7+
#############################################################################
8+
9+
####### Compiler, tools and options
10+
11+
CC = gcc
12+
CXX = g++
13+
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
14+
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
15+
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
16+
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I.
17+
LINK = g++
18+
LFLAGS =
19+
LIBS = $(SUBLIBS) -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread
20+
AR = ar cqs
21+
RANLIB =
22+
QMAKE = /usr/bin/qmake-qt4
23+
TAR = tar -cf
24+
COMPRESS = gzip -9f
25+
COPY = cp -f
26+
SED = sed
27+
COPY_FILE = $(COPY)
28+
COPY_DIR = $(COPY) -r
29+
STRIP = strip
30+
INSTALL_FILE = install -m 644 -p
31+
INSTALL_DIR = $(COPY_DIR)
32+
INSTALL_PROGRAM = install -m 755 -p
33+
DEL_FILE = rm -f
34+
SYMLINK = ln -f -s
35+
DEL_DIR = rmdir
36+
MOVE = mv -f
37+
CHK_DIR_EXISTS= test -d
38+
MKDIR = mkdir -p
39+
40+
####### Output directory
41+
42+
OBJECTS_DIR = ./
43+
44+
####### Files
45+
46+
SOURCES = main.cpp \
47+
dialog.cpp \
48+
util.cpp moc_dialog.cpp
49+
OBJECTS = main.o \
50+
dialog.o \
51+
util.o \
52+
moc_dialog.o
53+
DIST = /usr/share/qt4/mkspecs/common/unix.conf \
54+
/usr/share/qt4/mkspecs/common/linux.conf \
55+
/usr/share/qt4/mkspecs/common/gcc-base.conf \
56+
/usr/share/qt4/mkspecs/common/gcc-base-unix.conf \
57+
/usr/share/qt4/mkspecs/common/g++-base.conf \
58+
/usr/share/qt4/mkspecs/common/g++-unix.conf \
59+
/usr/share/qt4/mkspecs/qconfig.pri \
60+
/usr/share/qt4/mkspecs/features/qt_functions.prf \
61+
/usr/share/qt4/mkspecs/features/qt_config.prf \
62+
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
63+
/usr/share/qt4/mkspecs/features/default_pre.prf \
64+
/usr/share/qt4/mkspecs/features/debug.prf \
65+
/usr/share/qt4/mkspecs/features/default_post.prf \
66+
/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
67+
/usr/share/qt4/mkspecs/features/warn_on.prf \
68+
/usr/share/qt4/mkspecs/features/qt.prf \
69+
/usr/share/qt4/mkspecs/features/unix/thread.prf \
70+
/usr/share/qt4/mkspecs/features/moc.prf \
71+
/usr/share/qt4/mkspecs/features/resources.prf \
72+
/usr/share/qt4/mkspecs/features/uic.prf \
73+
/usr/share/qt4/mkspecs/features/yacc.prf \
74+
/usr/share/qt4/mkspecs/features/lex.prf \
75+
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
76+
qcryptdisk.pro
77+
QMAKE_TARGET = qcryptdisk
78+
DESTDIR =
79+
TARGET = qcryptdisk
80+
81+
first: all
82+
####### Implicit rules
83+
84+
.SUFFIXES: .o .c .cpp .cc .cxx .C
85+
86+
.cpp.o:
87+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
88+
89+
.cc.o:
90+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
91+
92+
.cxx.o:
93+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
94+
95+
.C.o:
96+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
97+
98+
.c.o:
99+
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
100+
101+
####### Build rules
102+
103+
all: Makefile $(TARGET)
104+
105+
$(TARGET): ui_dialog.h $(OBJECTS)
106+
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
107+
{ test -n "$(DESTDIR)" && DESTDIR="$(DESTDIR)" || DESTDIR=.; } && test $$(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $$DESTDIR" -ex quit '$(TARGET)' && test -f $(TARGET).gdb-index && objcopy --add-section '.gdb_index=$(TARGET).gdb-index' --set-section-flags '.gdb_index=readonly' '$(TARGET)' '$(TARGET)' && rm -f $(TARGET).gdb-index || true
108+
109+
Makefile: qcryptdisk.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \
110+
/usr/share/qt4/mkspecs/common/linux.conf \
111+
/usr/share/qt4/mkspecs/common/gcc-base.conf \
112+
/usr/share/qt4/mkspecs/common/gcc-base-unix.conf \
113+
/usr/share/qt4/mkspecs/common/g++-base.conf \
114+
/usr/share/qt4/mkspecs/common/g++-unix.conf \
115+
/usr/share/qt4/mkspecs/qconfig.pri \
116+
/usr/share/qt4/mkspecs/features/qt_functions.prf \
117+
/usr/share/qt4/mkspecs/features/qt_config.prf \
118+
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
119+
/usr/share/qt4/mkspecs/features/default_pre.prf \
120+
/usr/share/qt4/mkspecs/features/debug.prf \
121+
/usr/share/qt4/mkspecs/features/default_post.prf \
122+
/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
123+
/usr/share/qt4/mkspecs/features/warn_on.prf \
124+
/usr/share/qt4/mkspecs/features/qt.prf \
125+
/usr/share/qt4/mkspecs/features/unix/thread.prf \
126+
/usr/share/qt4/mkspecs/features/moc.prf \
127+
/usr/share/qt4/mkspecs/features/resources.prf \
128+
/usr/share/qt4/mkspecs/features/uic.prf \
129+
/usr/share/qt4/mkspecs/features/yacc.prf \
130+
/usr/share/qt4/mkspecs/features/lex.prf \
131+
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
132+
/usr/lib/i386-linux-gnu/libQtGui.prl \
133+
/usr/lib/i386-linux-gnu/libQtCore.prl
134+
$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile qcryptdisk.pro
135+
/usr/share/qt4/mkspecs/common/unix.conf:
136+
/usr/share/qt4/mkspecs/common/linux.conf:
137+
/usr/share/qt4/mkspecs/common/gcc-base.conf:
138+
/usr/share/qt4/mkspecs/common/gcc-base-unix.conf:
139+
/usr/share/qt4/mkspecs/common/g++-base.conf:
140+
/usr/share/qt4/mkspecs/common/g++-unix.conf:
141+
/usr/share/qt4/mkspecs/qconfig.pri:
142+
/usr/share/qt4/mkspecs/features/qt_functions.prf:
143+
/usr/share/qt4/mkspecs/features/qt_config.prf:
144+
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
145+
/usr/share/qt4/mkspecs/features/default_pre.prf:
146+
/usr/share/qt4/mkspecs/features/debug.prf:
147+
/usr/share/qt4/mkspecs/features/default_post.prf:
148+
/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
149+
/usr/share/qt4/mkspecs/features/warn_on.prf:
150+
/usr/share/qt4/mkspecs/features/qt.prf:
151+
/usr/share/qt4/mkspecs/features/unix/thread.prf:
152+
/usr/share/qt4/mkspecs/features/moc.prf:
153+
/usr/share/qt4/mkspecs/features/resources.prf:
154+
/usr/share/qt4/mkspecs/features/uic.prf:
155+
/usr/share/qt4/mkspecs/features/yacc.prf:
156+
/usr/share/qt4/mkspecs/features/lex.prf:
157+
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
158+
/usr/lib/i386-linux-gnu/libQtGui.prl:
159+
/usr/lib/i386-linux-gnu/libQtCore.prl:
160+
qmake: FORCE
161+
@$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile qcryptdisk.pro
162+
163+
dist:
164+
@$(CHK_DIR_EXISTS) .tmp/qcryptdisk1.0.0 || $(MKDIR) .tmp/qcryptdisk1.0.0
165+
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qcryptdisk1.0.0/ && $(COPY_FILE) --parents dialog.h util.h .tmp/qcryptdisk1.0.0/ && $(COPY_FILE) --parents main.cpp dialog.cpp util.cpp .tmp/qcryptdisk1.0.0/ && $(COPY_FILE) --parents dialog.ui .tmp/qcryptdisk1.0.0/ && (cd `dirname .tmp/qcryptdisk1.0.0` && $(TAR) qcryptdisk1.0.0.tar qcryptdisk1.0.0 && $(COMPRESS) qcryptdisk1.0.0.tar) && $(MOVE) `dirname .tmp/qcryptdisk1.0.0`/qcryptdisk1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qcryptdisk1.0.0
166+
167+
168+
clean:compiler_clean
169+
-$(DEL_FILE) $(OBJECTS)
170+
-$(DEL_FILE) *~ core *.core
171+
172+
173+
####### Sub-libraries
174+
175+
distclean: clean
176+
-$(DEL_FILE) $(TARGET)
177+
-$(DEL_FILE) Makefile
178+
179+
180+
check: first
181+
182+
mocclean: compiler_moc_header_clean compiler_moc_source_clean
183+
184+
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
185+
186+
compiler_moc_header_make_all: moc_dialog.cpp
187+
compiler_moc_header_clean:
188+
-$(DEL_FILE) moc_dialog.cpp
189+
moc_dialog.cpp: util.h \
190+
dialog.h
191+
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) dialog.h -o moc_dialog.cpp
192+
193+
compiler_rcc_make_all:
194+
compiler_rcc_clean:
195+
compiler_image_collection_make_all: qmake_image_collection.cpp
196+
compiler_image_collection_clean:
197+
-$(DEL_FILE) qmake_image_collection.cpp
198+
compiler_moc_source_make_all:
199+
compiler_moc_source_clean:
200+
compiler_uic_make_all: ui_dialog.h
201+
compiler_uic_clean:
202+
-$(DEL_FILE) ui_dialog.h
203+
ui_dialog.h: dialog.ui
204+
/usr/bin/uic-qt4 dialog.ui -o ui_dialog.h
205+
206+
compiler_yacc_decl_make_all:
207+
compiler_yacc_decl_clean:
208+
compiler_yacc_impl_make_all:
209+
compiler_yacc_impl_clean:
210+
compiler_lex_make_all:
211+
compiler_lex_clean:
212+
compiler_clean: compiler_moc_header_clean compiler_uic_clean
213+
214+
####### Compile
215+
216+
main.o: main.cpp dialog.h \
217+
util.h
218+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
219+
220+
dialog.o: dialog.cpp dialog.h \
221+
util.h \
222+
ui_dialog.h
223+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dialog.o dialog.cpp
224+
225+
util.o: util.cpp util.h
226+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o util.o util.cpp
227+
228+
moc_dialog.o: moc_dialog.cpp
229+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_dialog.o moc_dialog.cpp
230+
231+
####### Install
232+
233+
install: FORCE
234+
235+
uninstall: FORCE
236+
237+
FORCE:
238+

dialog.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#include "dialog.h"
2+
#include "ui_dialog.h"
3+
4+
Dialog::Dialog(QWidget *parent)
5+
: QDialog(parent), ui(new Ui::DialogClass)
6+
{
7+
ui->setupUi(this);
8+
}
9+
10+
Dialog::~Dialog()
11+
{
12+
delete ui;
13+
}
14+
15+
void
16+
Dialog::refresh()
17+
{
18+
ctab.refresh();
19+
fstab.refresh();
20+
mounts.refresh();
21+
22+
ui->tableWidget->setRowCount(ctab.cnt.size());
23+
QTableWidgetItem* item = 0;
24+
int r = 0;
25+
for(CryptTab::ContainerT::iterator i = ctab.cnt.begin();
26+
i != ctab.cnt.end();
27+
++i)
28+
{
29+
QString mp = fstab.mountpoint(i->first);
30+
if ( mp.length() ) {
31+
QString tooltip(i->second);
32+
33+
std::cerr << "found mountpoint: " << mp.toStdString() << " for " << i->first.toStdString() << std::endl;
34+
item = new QTableWidgetItem(i->first);
35+
item->setToolTip(tooltip);
36+
ui->tableWidget->setItem(r,0,item);
37+
38+
item = new QTableWidgetItem(mp);
39+
ui->tableWidget->setItem(r,1,item);
40+
41+
QString state = State2String(mounts.state(i->second, i->first));
42+
item = new QTableWidgetItem(state);
43+
ui->tableWidget->setItem(r,2,item);
44+
++r;
45+
}
46+
}
47+
48+
ui->tableWidget->setRowCount(r);
49+
//std::cerr << "row count now " << ui->tableWidget->rowCount() << std::endl;
50+
51+
}
52+
53+
void Dialog::on_button_refresh_clicked()
54+
{
55+
refresh();
56+
}
57+
58+
59+
void Dialog::on_button_mount_clicked()
60+
{
61+
QString name = get_current_name();
62+
std::cerr << "run mount for " << name.toStdString() << std::endl;
63+
run_mount(this, name);
64+
refresh();
65+
}
66+
67+
void Dialog::on_button_umount_clicked()
68+
{
69+
QString name = get_current_name();
70+
std::cerr << "run umount for " << name.toStdString() << std::endl;
71+
run_unmount(name);
72+
refresh();
73+
}
74+
75+
QString Dialog::get_current_name()
76+
{
77+
QList<QTableWidgetItem *> sel = ui->tableWidget->selectedItems();
78+
79+
// row-selection mode
80+
// we have 3 elements in row
81+
if (sel.size() != ui->tableWidget->columnCount()) {
82+
return QString();
83+
}
84+
85+
return sel[0]->text();
86+
}
87+
88+
void Dialog::on_tableWidget_doubleClicked(QModelIndex index)
89+
{
90+
QString name = get_current_name();
91+
QString location = ctab.location(name);
92+
93+
State state = mounts.state(location, name);
94+
if (state == mounted) {
95+
run_unmount(name);
96+
refresh();
97+
} else if (state == connected) {
98+
run_mount(this, name);
99+
refresh();
100+
}
101+
}
102+

dialog.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef DIALOG_H
2+
#define DIALOG_H
3+
4+
#include <QtGui/QDialog>
5+
6+
namespace Ui
7+
{
8+
class DialogClass;
9+
}
10+
11+
#include <util.h>
12+
13+
class Dialog : public QDialog,
14+
public Mount
15+
{
16+
Q_OBJECT
17+
18+
public:
19+
Dialog(QWidget *parent = 0);
20+
~Dialog();
21+
22+
void refresh();
23+
24+
private:
25+
Ui::DialogClass *ui;
26+
27+
QString get_current_name();
28+
29+
private slots:
30+
void on_tableWidget_doubleClicked(QModelIndex index);
31+
void on_button_mount_clicked();
32+
void on_button_umount_clicked();
33+
void on_button_refresh_clicked();
34+
};
35+
36+
#endif // DIALOG_H

0 commit comments

Comments
 (0)