OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Detect Sd Card Mount
bam
post Aug 13 2005, 02:09 PM
Post #1





Group: Members
Posts: 1,213
Joined: 9-June 05
From: Gobi Desert, Mongolia
Member No.: 7,306



need to know what mechanism triggers when you in sert the sd card, I want to auto move some *.pdb fils made by JPluckX from my sd card to my Documents directory.
Go to the top of the page
 
+Quote Post
boosalis
post Sep 23 2005, 10:47 AM
Post #2





Group: Members
Posts: 78
Joined: 28-January 04
From: clovis CA USA
Member No.: 1,580



bam

QCOP is your friend here. Don't have the code in front of me, but when I get home will try to post here at this forum the Qtopia event you register and listen for to get media mounts/dismounts
Go to the top of the page
 
+Quote Post
chrget
post Sep 23 2005, 11:07 PM
Post #3





Group: Members
Posts: 129
Joined: 29-May 04
Member No.: 3,485



QUOTE(boosalis @ Sep 23 2005, 08:47 PM)
QCOP is your friend here. [...]
*
Uhm, sounds like aiming a huge gun at a really tiny target.

I'd simply write a script that performs the task in question and would call that from /etc/sdcontrol when handling the insert action ...

Best regards,
Chris.
Go to the top of the page
 
+Quote Post
boosalis
post Sep 27 2005, 10:25 PM
Post #4





Group: Members
Posts: 78
Joined: 28-January 04
From: clovis CA USA
Member No.: 1,580



Bam - sorry for the delay in getting back to you with the source code. That is if you are still interested in capturing a event from inside your QT/Qtopia program/

channel = new QCopChannel( "QPE/Card", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(mediaAlert(const QCString&, const QByteArray&)) );

Hope the above signal/slot work, its been a while and I had it commented out in my code but recall it working at one time. The hard part I had was in figuring out what media device was loaded/unloaded. I did something crude like:

(sorry for this hack, but hope it gets the point home)
/**********************************************************/
void AllTracker::mediaAlert(const QCString & cstr, const QByteArray& ba)
{
bool mounted;
int status;
QByteArray cs;
QCString cs1;
QDir workDir("/mnt/card");
qDebug("MEDIA ALERT...");

mediaNotice = new
QMessageBox(tr("Media ALERT"),
cstr,
QMessageBox::Warning ,
QMessageBox:ohmy.gifk,0,0,
this,0,TRUE);
mediaNotice->exec();
delete mediaNotice;


if (cstr.contains("mtabChanged") != TRUE)
return;

// For some reason I could not do a read on /proc/mount so
// had to cat it to a normal file then read it
system("cat /proc/mounts > /tmp/mounts");
QFile mntFile("/tmp/mounts");
if (mntFile.exists() != TRUE) {
qWarning("Can't find /proc/mounts");
return;
}
status = mntFile.open(IO_ReadOnly );
if (status != TRUE) {
qWarning("Can't open /tmp/mounts");
return;
}
cs = mntFile.readAll();
if (cs.size() < 1) {
qWarning("No data in /tmp/mounts");
return;
}
cs1 = cs;
if (cs1.contains("card")) {
qDebug("Found mnt");
mounted = TRUE;
}
else {
qDebug("Media Not found");
mounted = FALSE;
}
if (mounted == FALSE) {
if (run == 0)
return;
qDebug("work dir == 0");
mediaNotice = new
QMessageBox(tr("Media Removal Warning"),
tr("Save transactions before\nremoving media"),
QMessageBox::Warning ,
QMessageBox:ohmy.gifk,0,0,
this,0,TRUE);
mediaNotice->exec();
delete mediaNotice;
mediaNotice = 0;
}
else { // is mounted
QApplication::beep();
if (run == 0) {
loadData();
return;
}

if (turnOffMedia != TRUE) {
mediaNotice = new
QMessageBox(tr("Medial Alert"),
tr("Reload Data from Media"),
QMessageBox::Information ,
QMessageBox::Yes,
QMessageBox::No,0,
this,0,TRUE);
status = mediaNotice->exec();
delete mediaNotice;
mediaNotice = 0;
qDebug("status =f media dialog = %d",status);
turnOffMedia = FALSE;
}

}
}




QUOTE(boosalis @ Sep 23 2005, 10:47 AM)
bam

QCOP is your friend here.  Don't have the code in front of me, but when I get home will try to post here at this forum the Qtopia event you register and listen for to get media mounts/dismounts
*
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th July 2014 - 12:14 AM