Index: mdbmigrate.h
===================================================================
--- mdbmigrate.h	(revision 483261)
+++ mdbmigrate.h	(working copy)
@@ -33,6 +33,7 @@
 	class MDBMigrate : public KexiMigrate
 	{
 		Q_OBJECT
+		KEXIMIGRATION_DRIVER
 		
 		public:
 			MDBMigrate(QObject *parent, const char *name, const QStringList& args = QStringList());
@@ -47,8 +48,11 @@
 			void MySQLMigrate::getConstraints(int mysqlConstraints, KexiDB::Field* fld);
 			void MySQLMigrate::getOptions(int flags, KexiDB::Field* fld);
 */
+			//! Reimplemented to add support for "sourceDatabaseHasNonUnicodeEncoding" property
+//! @todo this in fact should be in Connection class but Migration framework has no such yet!
+			virtual QVariant propertyValue( const QCString& propName );
 
-    protected:
+	protected:
 			//Driver specific function to return table names
 			virtual bool drv_tableNames(QStringList& tablenames);
 			
@@ -69,15 +73,10 @@
 			virtual bool drv_progressSupported() { return true; }
 			virtual bool drv_getTableSize(const QString& table, Q_ULLONG& size);
 
-		/*! driver's static version information, it is automatically implemented
-		 in implementation using KEXIDB_DRIVER macro (see driver_p.h) */
-		virtual int versionMajor() const;
-		virtual int versionMinor() const;
-		
 		private:
-      void initBackend();
-      void releaseBackend();
-      MdbHandle *mdb;
+			void initBackend();
+			void releaseBackend();
+			MdbHandle *m_mdb;
 	};
 }
 
Index: keximigrate_mdb.desktop
===================================================================
--- keximigrate_mdb.desktop	(revision 483261)
+++ keximigrate_mdb.desktop	(working copy)
@@ -16,3 +16,4 @@
 X-Kexi-MigrationDriverName=Access
 X-Kexi-MigrationDriverType=File
 X-Kexi-FileDBDriverMime=application/x-msaccess
+X-Kexi-KexiMigrationVersion=1.1
Index: mdbmigrate.cpp
===================================================================
--- mdbmigrate.cpp	(revision 483261)
+++ mdbmigrate.cpp	(working copy)
@@ -41,6 +41,13 @@
                        const QStringList &args) :
 	KexiMigrate(parent, name, args)
 {
+  m_properties["source_database_has_nonunicode_encoding"] = QVariant( true, 1 );
+  m_propertyCaptions["source_database_has_nonunicode_encoding"] 
+	  = i18n("Source Database Has Non-Unicode Encoding");
+  m_properties["source_database_nonunicode_encoding"] = QVariant("");
+  m_propertyCaptions["source_database_nonunicode_encoding"] 
+	  = i18n("Source Database Non-Unicode Encoding");
+
   initBackend();
 }
 
@@ -58,21 +65,42 @@
   mdb_exit();
 }
 
+QVariant MDBMigrate::propertyValue( const QCString& propName )
+{
+	if (propName == "source_database_has_nonunicode_encoding") {
+		m_properties["source_database_has_nonunicode_encoding"] = QVariant(false, 0);
+		//costly, but we need this to get this property from file...
+		drv_connect();
+		drv_disconnect();
+	}
+	return KexiMigrate::propertyValue( propName );
+}
+
 /* ************************************************************************** */
 /*! Connect to the db backend */
 bool MDBMigrate::drv_connect() {
   kdDebug() << "mdb_open:" << endl;
-  KexiDB::ConnectionData *m_data = m_migrateData->source;
+  KexiDB::ConnectionData *data = m_migrateData->source;
 
   // mdb_open takes a char*, not const char*, hence this nonsense.
-  char *filename = qstrdup(QFile::encodeName(m_data->fileName()));
-  mdb = mdb_open (filename, MDB_NOFLAGS);
+  char *filename = qstrdup(QFile::encodeName(data->fileName()));
+  m_mdb = mdb_open (filename, MDB_NOFLAGS);
   delete [] filename;
 
-  if (!mdb) {
+  if (!m_mdb) {
     kdDebug() << "mdb_open failed." << endl;
     return false;
   }
+
+  //setting source encoding
+  if (!m_properties["source_database_nonunicode_encoding"].toCString().isEmpty()) {
+    mdb_set_encoding(m_mdb, (const char*)m_properties["source_database_nonunicode_encoding"].toCString());
+    kdDebug() << "non-unicode encoding set to \"" << m_properties["source_database_nonunicode_encoding"].toCString() << "\"" << endl;
+  }
+
+  //supports setting source encoding
+  m_properties["source_database_has_nonunicode_encoding"] = QVariant( IS_JET3(m_mdb), 1 );
+  
   return true;
 }
 
@@ -80,7 +108,7 @@
 /*! Disconnect from the db backend */
 bool MDBMigrate::drv_disconnect()
 { 
-  mdb_close(mdb);
+  mdb_close(m_mdb);
   return true;
 }
 
@@ -95,9 +123,9 @@
   MdbTableDef *tableDef = 0;
 
   // Look through each entry in the catalogue ...
-  for (unsigned int i = 0; i < mdb->num_catalog; i++) {
+  for (unsigned int i = 0; i < m_mdb->num_catalog; i++) {
     MdbCatalogEntry* dbObject = 
-        (MdbCatalogEntry*)(g_ptr_array_index (mdb->catalog, i));
+        (MdbCatalogEntry*)(g_ptr_array_index (m_mdb->catalog, i));
 
     // ... for a table with the given name
     if (dbObject->object_type == MDB_TABLE) {
@@ -166,15 +194,15 @@
 bool MDBMigrate::drv_tableNames(QStringList& tableNames)
 {
   // Try to read the catalogue of database objects
-  if (!mdb_read_catalog (mdb, MDB_ANY)) {
+  if (!mdb_read_catalog (m_mdb, MDB_ANY)) {
     kdDebug() << "MDBMigrate::drv_tableNames: couldn't read catalogue" << endl;
     return false;
   }
 
   // Add non-system tables to the list
-  for (unsigned int i = 0; i < mdb->num_catalog; i++) {
+  for (unsigned int i = 0; i < m_mdb->num_catalog; i++) {
     MdbCatalogEntry* dbObject = 
-        (MdbCatalogEntry*)(g_ptr_array_index (mdb->catalog, i));
+        (MdbCatalogEntry*)(g_ptr_array_index (m_mdb->catalog, i));
     if (dbObject->object_type == MDB_TABLE) {
       QString dbObjectName = QString::fromUtf8(dbObject->object_name);
       if (!dbObjectName.startsWith("MSys")) {
@@ -263,21 +291,21 @@
   while(mdb_fetch_row(tableDef)) {
     QValueList<QVariant> vals = QValueList<QVariant>();
 
-    kdDebug() << kdLoc << "Copying " << tableDef->num_cols << " cols" << endl;
+//    kdDebug() << kdLoc << "Copying " << tableDef->num_cols << " cols" << endl;
     for (unsigned int i = 0; i < tableDef->num_cols; i++) {
       MdbColumn *col = (MdbColumn*) g_ptr_array_index(tableDef->columns, i);
 
       if (col->col_type == MDB_OLE && col->cur_value_len) {
-        kdDebug() << kdLoc << "OLE!! @ " << i << endl;
-        mdb_ole_read(mdb, col, columnData[i], MDB_BIND_SIZE);
+//        kdDebug() << kdLoc << "OLE!! @ " << i << endl;
+        mdb_ole_read(m_mdb, col, columnData[i], MDB_BIND_SIZE);
       }
 
       //! @todo: How to import binary data?
       QVariant var = toQVariant(columnData[i], columnDataLength[i],
                               col->col_type);
-      kdDebug() << kdLoc << " col=" << i 
-              << " data=" << columnData[i] 
-              << " qvar=" << var.toString() << endl;
+//      kdDebug() << kdLoc << " col=" << i 
+//              << " data=" << columnData[i] 
+//              << " qvar=" << var.toString() << endl;
       vals << var;
     }
     destConn->insertRecord(*dstTable, vals);
@@ -375,8 +403,8 @@
   for (unsigned int i = 0; i < tableDef->num_idxs; i++) {
     idx = (MdbIndex*) g_ptr_array_index (tableDef->indices, i);
     QString fldName = QString::fromUtf8(idx->name);
-    kdDebug() << kdLoc << "got index "
-        << fldName << "\"" << idx->name << endl;
+//    kdDebug() << kdLoc << "got index "
+//        << fldName << "\"" << idx->name << endl;
     if (!strcmp(idx->name, "PrimaryKey")) {
       idx = (MdbIndex*) g_ptr_array_index (tableDef->indices, i);
       foundIdx = true;
@@ -411,8 +439,9 @@
 
   //! ... and add it to the table definition
   // but only if the PK has only one field, so far :o(
-  if(idx->num_keys == 1) {
-    table->field(idx->key_col_num[0] - 1)->setPrimaryKey(true);
+	KexiDB::Field *f;
+  if(idx->num_keys == 1 && (f = table->field(idx->key_col_num[0] - 1))) {
+		f->setPrimaryKey(true);
   } else {
     //! @todo: How to add a composite PK to a TableSchema?
     //m_table->setPrimaryKey(p_idx);
