Not able to update firefox sqlite database when firefox is running-MacOS - objective-c

I have the following code snippet to update firefox extension sqlite data base
NSString * profileFolderPath = [[ #"~" stringByExpandingTildeInPath] stringByAppendingPathComponent:#"/Library/Application Support/Firefox/Profiles"];
NSString *sqlitePath = [pathToProfileFolder stringByAppendingPathComponent:#"extensions.sqlite"];
int rc = sqlite3_open([sqlitePath UTF8String], &db);
if( rc )
{
NSLog(#"enable extension :%#\n",[NSString stringWithCString:sqlite3_errmsg(db)]);
sqlite3_close(db);
return NO;
}
else {
NSLog(#"opened entensions db successfully \n");
}
// check the values for active and userDisabled fields
rc = sqlite3_exec(db,"SELECT active,userDisabled FROM addon where id='myId.com'",sqliteCallback,0,&zErrMsg);
if (rc!=SQLITE_OK ) {
NSLog(#"error quering the entensions database :%#\n",[NSString stringWithCString:zErrMsg]);
if(zErrMsg)
sqlite3_free(zErrMsg);
sqlite3_close(db);
return NO;
// handle error
}
When firefox application is not in running state,I can read the values and also update the database,but when the firefox is running I am not able to read the values from the database as sqlite3_exec statement is returning the value 5 and I can see the error in console saying "error quering the extensions database :database is locked".
How can I resolve this issue.Please help.

You cannot b/c firefox keeps its own config file (and extensions db file IS a firefox own config file) open while it runs.

Related

How to insert data in database after payment successful through instamojo

I have integrated instamojo payment api with my website on PHP.
I can also insert data into my database before payment api is called.
Now how can i insert data into my database after my payment is successful !
Thanks
You have to save this code as php file in your host and then set this file URL as web hook URL for Product/Payment link in Instamojo. You can also check whether this works on Web hook checking page in Instamojo.
<?php
/*
Basic PHP script to handle Instamojo RAP webhook.
*/
$data = $_POST;
$mac_provided = $data['mac']; // Get the MAC from the POST data
unset($data['mac']); // Remove the MAC key from the data.
$ver = explode('.', phpversion());
$major = (int) $ver[0];
$minor = (int) $ver[1];
if($major >= 5 and $minor >= 4){
ksort($data, SORT_STRING | SORT_FLAG_CASE);
}
else{
uksort($data, 'strcasecmp');
}
// You can get the 'salt' from Instamojo's developers page(make sure to log in first): https://www.instamojo.com/developers
// Pass the 'salt' without <>
$mac_calculated = hash_hmac("sha1", implode("|", $data), "<YOUR_SALT>");
if($mac_provided == $mac_calculated){
if($data['status'] == "Credit"){
// Payment was successful, mark it as successful in your database.
// You can acess payment_request_id, purpose etc here.
}
else{
// Payment was unsuccessful, mark it as failed in your database.
// You can acess payment_request_id, purpose etc here.
}
}
else{
echo "MAC mismatch";
}
?>

Unable to update unidata from .NET

I've been attempting for the last couple of days to update unidata using sample code as a basis using .NET without success. I can read the database successfully and view the raw data within visual studio. The error reported back is a out of range error. The program is attempting to update the unit price of a purchase order.
Error:
{" Error on Socket Receive. Index was outside the bounds of the array.POD"}
[IBMU2.UODOTNET.UniFileException]: {" Error on Socket Receive. Index was outside the bounds of the array.POD"}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
HResult: -2146232832
InnerException: null
Message: " Error on Socket Receive. Index was outside the bounds of the array.POD"
Source: "UniFile Class"
StackTrace: " at IBMU2.UODOTNET.UniFile.Write()\r\n at IBMU2.UODOTNET.UniFile.Write(String aRecordID, UniDynArray aRecordData)\r\n at ReadXlsToUnix.Form1.TestUpdate(String PO_LINE_SHIP, String price) in c:\Users\xxx\Documents\Visual Studio 2013\Projects\ReadXlsToUnix\ReadXlsToUnix\Form1.cs:line 330"
TargetSite: {Void Write()}
failing Test Code is:
private void TestUpdate(string PO_LINE_SHIP,string price)
{
UniFile pod =null;
UniSession uniSession =null;
//connection string
uniSession = UniObjects.OpenSession("unixMachine", "userid", Properties.Settings.Default.PWD, "TRAIN", "udcs");
//open file
pod = uniSession.CreateUniFile("POD");
//read data
pod.Read(PO_LINE_SHIP);
//locking strategy
pod.UniFileLockStrategy = 1;
pod.UniFileReleaseStrategy = 1;
if (pod.RecordID == ""){
pod.UnlockRecord();
}
//replace existing value with one entered by user
pod.Record.Replace(4, (string)uniSession.Iconv(price, "MD4"));
try
{
pod.Write(pod.RecordID,pod.Record); //RecordId and Record both show correctly hover/immediate window
//pod.Write() fails with same message
}
catch (Exception err)
{
MessageBox.Show("Error" + err);
}
pod.Close();
UniObjects.CloseSession(uniSession);
}
}
Running on HP UX 11.31 unidata 7.2 and using UODOTNET.dll 2.2.3.7377
Any help greatly appreciated.
This is the write record version and have also tried writefield functionality with same error.
Rajan - thanks for the update and link. I have tried unsuccessfully to read/update my unidata tables using the U2 Toolkit. I can however read/update a file I have created within the same account. Does this mean there is a missing entry somewhere VOC, DICT for example.

Selenium RC PHPUnit test

My testcase crashes with the following error:
$this->open("/en");
$this->type("id=LoginForm_username", "seleniumfree");
$this->type("id=LoginForm_password", "seleniumfree");
$this->click("name=login");
$this->waitForPageToLoad("30000");
$this->click("link=Calendar");
$this->waitForPageToLoad("30000");
$this->click("link=Add to agenda");
$this->type("id=UserAgenda_date", "2013-10-10");
$this->select("id=UserAgenda_time", "label=01:00");
$note = $this->getEval("Math.floor(Math.random()*1000)").':note';
$this->type("id=UserAgenda_note", $note);
$this->click("name=yt0");
sleep(5);
try { //also tried with integer
$this->assertEquals("2", $this->getXpathCount("//input[#value='"+ $note + "']"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/':
ERROR: Command execution failure. Please search the user group at https://groups.google.com/forum/#!forum/selenium-users for error details from the log window.
The error message is: The expression cannot be converted to return the specified type.
In firefox IDE, playing the test runs fine.Is there another way I can count the inputs by value?

How to follow alias with libldap?

I have an openvpn plugin which allows me to use ldap authentication. But my LDAP directory contains aliases and it seems that openvpn-auth-ldap doesn't follow them.
- (id) initWithURL: (LFString *) url timeout: (int) timeout {
...
ldap_initialize(&ldapConn, [url cString]);
if (!ldapConn) {
[TRLog error: "Unable to initialize LDAP server %s", [url cString]];
[self release];
return (NULL);
}
_timeout = timeout;
ldapTimeout.tv_sec = _timeout;
ldapTimeout.tv_usec = 0;
if (ldap_set_option(ldapConn, LDAP_OPT_NETWORK_TIMEOUT, &ldapTimeout) != LDAP_OPT_SUCCESS)
[TRLog warning: "Unable to set LDAP network timeout."];
Is there anyway I can fix it ?
By default, LDAP_OPT_DEREF is setted to LDAP_DEREF_NEVER. Maybe you should force alias deferencing of your ldap connection :
int deref = LDAP_DEREF_ALWAYS;
ldap_set_option(ldapConn, LDAP_OPT_DEREF, &deref)

SQLite iphone data lost when rebooting or closing the app

I have a question... I have an application using sqlite to save some data.Everything works perfectly, meaning I can add, delete, view data. The data are persistent when the application goes into background. Now, when I remove the application from memory or reboot the iPhone, the database is corrupted and all the data are messed up !
I have a class call dbAccess where all the database actions are define(add, delete, retreive rows). At the end I have a finalize action, that finalize all the statement used and then close the database.
+ (void)finalizeStatements{
NSLog(#"Finalizing the Delete Statements");
if(deleteStmt) {
NSLog(#"Delete Statement exist... finalization");
sqlite3_finalize(deleteStmt);
deleteStmt = nil;
}
NSLog(#"Finalizing the Add Statements");
if(addStmt) {
NSLog(#"Add Statement exist... finalization");
sqlite3_finalize(addStmt);
addStmt = nil;
}
NSLog(#"Finalizing the Store Statements");
if(storeStmt) {
NSLog(#"Store Statement exist... finalization");
sqlite3_finalize(storeStmt);
storeStmt = nil;
}
NSLog(#"Finalizing the Agent Statements");
if(agentStmt) {
NSLog(#"Agent Statement exist... finalization");
sqlite3_finalize(agentStmt);
agentStmt = nil;
}
NSLog(#"Closing the Database");
if(database) {
NSLog(#"The database exist... closing it");
sqlite3_close(database);
}
}
This method is called by the application delegate when applicationDidEnterBackground and applicationWillTerminate. An openDatabase method is call when applicationDidBecomeActive.
Any ideas why the database is corrupted ?
Thanks.
First off, check out fmdb or some other proven wrappers. You can also browse the code.
Not sure if there's enough info to know why it's corrupt. But, you should get return codes from ALL sqlite3_xxx calls and log at a minimum to understand what's going on or you may just be blasting past an issue.
Also, make sure to call sqlite_errmsg which will offer more clues if the return code is not success.
In my wrapper, I do this in close. It's expected that statements are finalized bu handled if not. I have a statement cache which on clear finalizes each statement.
:
- (void)close
{
if (_sqlite3)
{
NSLog(#"closing");
[self clearStatementCache];
int rc = sqlite3_close(_sqlite3);
NSLog(#"close rc=%d", rc);
if (rc == SQLITE_BUSY)
{
NSLog(#"SQLITE_BUSY: not all statements cleanly finalized");
sqlite3_stmt *stmt;
while ((stmt = sqlite3_next_stmt(_sqlite3, 0x00)) != 0)
{
NSLog(#"finalizing stmt");
sqlite3_finalize(stmt);
}
rc = sqlite3_close(_sqlite3);
}
if (rc != SQLITE_OK)
{
NSLog(#"close not OK. rc=%d", rc);
}
_sqlite3 = NULL;
}
}