Exemple #1
0
        public void Process(IRimUtility pRimUtility, IRimDatabaseAccess pRimDeviceAccess    )
        {
            logger = (IRimLogger)pRimUtility;
            logger.LogLevel = eRIM_LogLevel.RIM_Logger_Verbose;
            logger.LogDebug(eRIM_LogLevel.RIM_Logger_Verbose, 100, "KeePassBB2 Sync Starting");

            progressForm = new ProgressForm();
            progressForm.Show();

            IRimTable dboTable = null;
            IRimRecords records = null;

            try
            {
                dboTable = getTable(pRimDeviceAccess);
                records = dboTable.LoadRecords(eRIM_Mode.RIM_Mode_Write);
            }
            catch (Exception e)
            {
                logger.LogStatus("Couldn't retrieve the sync object.  KeePass for BlackBerry v2 either isn't loaded on the device or is configured for External File Mode. " + e.ToString());
                MessageBox.Show("KeePass for BlackBerry v2 either isn't loaded on the device or is configured for External File Mode.");
                closeProgress();
                return;
            }

            String dbFilename = getDBPath();
            if (dbFilename == null)
            {
                Configure(null, 0);
                dbFilename = getDBPath();
                if (dbFilename == null || dbFilename.Length == 0)
                {
                    logger.LogStatus("No database path was specified.");
                    MessageBox.Show("You must specify a database file.");
                    closeProgress();
                    return;
                }
            }

            logger.LogStatus("Using " + dbFilename);
            FileInfo fi = new FileInfo(dbFilename);
            if (!fi.Exists)
            {
                logger.LogStatus("The database file does not exist.");
                MessageBox.Show("The database file specified in the configuration does not exist.");
                closeProgress();
                return;
            }

            if (!checkPassword())
            {
                logger.LogStatus("A password/keyfile was not specified.");
                MessageBox.Show("You must specify a password and/or keyfile.");
                closeProgress();
                return;
            }

            try
            {
                sendCredentials(records);
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception transmitting the credentials. " + e.ToString());
                MessageBox.Show("There was an exception transmitting the credentials. " + e.ToString());
                closeProgress();
                return;
            }
            try
            {
                sendFile(records, dbFilename);
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception sending the file. " + e.ToString());
                MessageBox.Show("There was an exception sending the file. " + e.ToString());
                closeProgress();
                return;
            }

            try
            {
                logger.LogStatus("Receiving data from device");
                setProgress("Receiving data from device");
                records = dboTable.LoadRecords(eRIM_Mode.RIM_Mode_Read);
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception receiving the file. " + e.ToString());
                MessageBox.Show("There was an exception receiving the file. " + e.ToString());
                closeProgress();
                return;
            }

            //            if (GetValue(dbFilename, records, out displayMsg)) return;
            IRimTable devTracTable = getTable(pRimDeviceAccess);
            var devRecords = devTracTable.LoadRecords(eRIM_Mode.RIM_Mode_Read);
            string recordsString = "RecordNum: " + devRecords.Count + "";
            foreach (IRimRecord record in devRecords)
            {
                recordsString += "[" + record + "]";
                recordsString += AppendFields(record.fields);
            }

            MessageBox.Show("testing sync api:" + recordsString, "DevTrac Sync Add-In");
            logger.LogStatus("Completed.");

            //            if (displayMsg != null)
            //            {
            //                MessageBox.Show(displayMsg, "KeePassBB2 Sync Add-In");
            //            }

            setProgress("Completed");
            closeProgress();
        }
Exemple #2
0
        public void Process(IRimUtility pRimUtility, IRimDatabaseAccess pRimDeviceAccess)
        {
            logger = (IRimLogger)pRimUtility;
            logger.LogLevel = eRIM_LogLevel.RIM_Logger_Verbose;
            logger.LogDebug(eRIM_LogLevel.RIM_Logger_Verbose, 100, "KeePassBB2 Sync Starting");

            progressForm = new ProgressForm();
            progressForm.Show();

            IRimTable dboTable = null;
            IRimRecords records = null;

            try
            {
                dboTable = getTable(pRimDeviceAccess);
                records = dboTable.LoadRecords(eRIM_Mode.RIM_Mode_Write);
            }
            catch (Exception e)
            {
                logger.LogStatus("Couldn't retrieve the sync object.  KeePass for BlackBerry v2 either isn't loaded on the device or is configured for External File Mode. " + e.ToString());
                MessageBox.Show("KeePass for BlackBerry v2 either isn't loaded on the device or is configured for External File Mode.");
                closeProgress();
                return;
            }

            String dbFilename = getDBPath();
            if (dbFilename == null)
            {
                Configure(null, 0);
                dbFilename = getDBPath();
                if (dbFilename == null || dbFilename.Length == 0)
                {
                    logger.LogStatus("No database path was specified.");
                    MessageBox.Show("You must specify a database file.");
                    closeProgress();
                    return;
                }
            }

            logger.LogStatus("Using " + dbFilename);
            FileInfo fi = new FileInfo(dbFilename);
            if (!fi.Exists)
            {
                logger.LogStatus("The database file does not exist.");
                MessageBox.Show("The database file specified in the configuration does not exist.");
                closeProgress();
                return;
            }

            if (!checkPassword())
            {
                logger.LogStatus("A password/keyfile was not specified.");
                MessageBox.Show("You must specify a password and/or keyfile.");
                closeProgress();
                return;
            }

            try
            {
                sendCredentials(records);
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception transmitting the credentials. " + e.ToString());
                MessageBox.Show("There was an exception transmitting the credentials. " + e.ToString());
                closeProgress();
                return;
            }
            try
            {
                sendFile(records, dbFilename);
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception sending the file. " + e.ToString());
                MessageBox.Show("There was an exception sending the file. " + e.ToString());
                closeProgress();
                return;
            }

            try
            {
                logger.LogStatus("Receiving data from device");
                setProgress("Receiving data from device");
                records = dboTable.LoadRecords(eRIM_Mode.RIM_Mode_Read);
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception receiving the file. " + e.ToString());
                MessageBox.Show("There was an exception receiving the file. " + e.ToString());
                closeProgress();
                return;
            }

            StatusMessage sm;
            String displayMsg = null;
            try
            {
                sm = getStatusMessage(records);
                logger.LogStatus("Return Status: "+sm.rc+": "+sm.msg);
                switch (sm.rc)
                {
                    case RC_DESKTOP_DECRYPT_FAILURE:
                    case RC_DEVICE_DECRYPT_FAILURE:
                        displayMsg = sm.msg;
                        password = null;
                        keyfile = null;
                        break;
                    case RC_NOT_SUPPORTED:
                    case RC_LOADED_TO_DEVICE:
                        displayMsg = sm.msg;
                        break;
                    case RC_NO_CHANGES_MADE:
                        //displayMsg = "No changes detected";
                        break;
                    case RC_CHANGES_MADE:
                        //displayMsg = "Completed";
                        saveFile(records, dbFilename);
                        break;
                    default:
                        displayMsg = "There was an error on the device: " + sm.msg;
                        break;
                }
            }
            catch (Exception e)
            {
                logger.LogStatus("There was an exception receiving the status string. " + e.ToString());
                MessageBox.Show("There was an exception receiving the status string. " + e.ToString());
                return;
            }
            logger.LogStatus("Completed.");

            if (displayMsg != null)
            {
                MessageBox.Show(displayMsg, "KeePassBB2 Sync Add-In");
            }

            setProgress("Completed");
            closeProgress();
        }