diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/.gitignore | 1 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 38 | ||||
-rw-r--r-- | examples/Makefile | 8 | ||||
-rw-r--r-- | examples/viewer/CMakeLists.txt | 31 | ||||
-rw-r--r-- | examples/viewer/Makefile | 18 | ||||
-rw-r--r-- | examples/viewer/viewer.cpp | 4 |
6 files changed, 71 insertions, 29 deletions
diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index 4fef1718..00000000 --- a/examples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/example[0-9] diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..9e6998fb --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,38 @@ + +IF(VMIME_BUILD_SAMPLES) + + ADD_SUBDIRECTORY(viewer) + + FILE( + GLOB + VMIME_SAMPLES_SRC_FILES + ${CMAKE_SOURCE_DIR}/examples/*.cpp + ) + + # Build one file for each sample + FOREACH(VMIME_SAMPLE_SRC_FILE ${VMIME_SAMPLES_SRC_FILES}) + + GET_FILENAME_COMPONENT(VMIME_SAMPLE_NAME "${VMIME_SAMPLE_SRC_FILE}" NAME_WE) + + ADD_EXECUTABLE( + ${VMIME_SAMPLE_NAME} + ${VMIME_SAMPLE_SRC_FILE} + ) + + TARGET_LINK_LIBRARIES( + ${VMIME_SAMPLE_NAME} + ${VMIME_LIBRARY_NAME} + ) + + ADD_DEPENDENCIES( + ${VMIME_SAMPLE_NAME} + ${VMIME_LIBRARY_NAME} + ) + + ENDFOREACH() + +ELSE() + + MESSAGE(FATAL_ERROR "Examples are not to be built (set VMIME_BUILD_SAMPLES to YES.") + +ENDIF() diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 640ba253..00000000 --- a/examples/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: example1 example6 - -example1: example1.cpp ../libvmime-debug.a - g++-mp-4.8 -o example1 example1.cpp -I.. ../libvmime-debug.a -L /opt/local/lib -lgnutls -lgsasl -liconv - -example6: example6.cpp ../libvmime-debug.a - g++-mp-4.8 -o example6 example6.cpp -I.. ../libvmime-debug.a -L /opt/local/lib -lgnutls -lgsasl -liconv - diff --git a/examples/viewer/CMakeLists.txt b/examples/viewer/CMakeLists.txt new file mode 100644 index 00000000..c8d93163 --- /dev/null +++ b/examples/viewer/CMakeLists.txt @@ -0,0 +1,31 @@ + +IF(VMIME_BUILD_SAMPLES) + + FIND_PACKAGE(PkgConfig REQUIRED) + PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0) + + INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS}) + LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS}) + ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER}) + + ADD_EXECUTABLE( + viewer + viewer.cpp + ) + + TARGET_LINK_LIBRARIES( + viewer + ${VMIME_LIBRARY_NAME} + ${GTK3_LIBRARIES} + ) + + ADD_DEPENDENCIES( + viewer + ${VMIME_LIBRARY_NAME} + ) + +ELSE() + + MESSAGE(FATAL_ERROR "Examples are not to be built (set VMIME_BUILD_SAMPLES to YES.") + +ENDIF() diff --git a/examples/viewer/Makefile b/examples/viewer/Makefile deleted file mode 100644 index f0401c5d..00000000 --- a/examples/viewer/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -COMPILER=g++ -CFLAGS=-g -I ../.. `pkg-config --cflags gtk+-2.0` -LDFLAGS=-I ../.. `pkg-config --libs gtk+-2.0` -lgnutls -lgsasl - - -viewer: viewer.o ../../libvmime-debug.a - $(COMPILER) $(LDFLAGS) -o viewer viewer.o ../../libvmime-debug.a - -viewer.o: viewer.cpp - $(COMPILER) $(CFLAGS) -c -o viewer.o viewer.cpp - -../../libvmime-debug.a: - @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - @echo "! You must build VMime library before compiling the example !" - @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - @false - diff --git a/examples/viewer/viewer.cpp b/examples/viewer/viewer.cpp index c684c140..77303fa6 100644 --- a/examples/viewer/viewer.cpp +++ b/examples/viewer/viewer.cpp @@ -52,14 +52,14 @@ vmime::ref <vmime::message> currentMessage = NULL; -void insertRowInModel(GtkTreeStore* model, vmime::ref <const vmime::component> comp, GtkTreeIter* parent = NULL) +void insertRowInModel(GtkTreeStore* model, vmime::ref <vmime::component> comp, GtkTreeIter* parent = NULL) { GtkTreeIter iter; gtk_tree_store_append(model, &iter, parent); gtk_tree_store_set(model, &iter, 0, typeid(*comp).name(), 1, comp.get(), -1); - const std::vector <vmime::ref <const vmime::component> > children = comp->getChildComponents(); + const std::vector <vmime::ref <vmime::component> > children = comp->getChildComponents(); for (int i = 0 ; i < children.size() ; ++i) { |