×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    How to index file by Tracker?

    Hello,
    I try to send saved QImage via ShareUI. There is no problems when file with image had been already opened in Gallery app. But if file is new - there is no preview in Share UI interface and no services listed, only "Create new account".
    As i understand the problem is that my saved image file is not indexed in Tracker database.
    Is there any simple way to index file by Tracker?

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: How to index file by Tracker?

    Nobody know? Or i asked something wrong?

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    2

    Re: How to index file by Tracker?

    Hi,

    Sorry for the late replay, I didn't see this thread.

    To make that image indexed by Tracker, just save it in the "images" folder. Tracker will discover it automatically extract the metadata and classify it as image (this can take a couple of seconds). Then it will be also visible in Gallery.

    There are a couple of special cases though: sometimes you don't want the image visible in the Gallery, or that couple of seconds are too much waiting for your UI. In those cases, the application can help tracker providing the basic data. It can send an sparql like this before writing the image in the filesystem:

    INSERT {
    _:1 a nfoataObject, nmm:Photo;
    nie:url "/home/user/path/to/the/future/picture";
    nfo:width "120";
    nfo:height "123".
    }

    This INSERT will return the URI inside Tracker. This can be executed in the command line with tracker-sparql -q "INSERT { ... }" or using QSparql.

    What happens in this case is that the application says "there will be an image in this location", which is enough for the Share UI. Then tracker will complete the metadata when the file is ready. The camera does this to move quickly to the Share UI.

    Hope this helps. Note that Tracker is open source and the developers (including me as "frade") are available in #Tracker in GIMPnet. I am also available in #meego@freenode. Feel free to come and ask.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: How to index file by Tracker?

    Hi ifrade,
    Thank you for your reply. Sorry, but i new in SPARQL.
    I wrote such code:

    void registerInTracker(QString fileName)
    {
    QSparqlConnection connection("QTRACKER_DIRECT");
    if (!connection.isValid())
    return;
    QString queryStr = "INSERT {_:1 a nfo:dataObject, nmm:Photo; nie:url \"";
    queryStr += fileName;
    queryStr += "\"nfo:width \"120\"; nfo:height \"123\" . }";

    QSparqlQuery query(queryStr);
    QSparqlResult* result = connection.syncExec(query);
    }
    and receive such errors in application output:

    QTrackerDirectSyncResult: QSparqlError(0, "GDBus.Error:org.freedesktop.Tracker1.SparqlError.Parse: 1.1: syntax error, INSERT and DELETE are not supported in query mode", 2) "INSERT {_:1 a nfo:dataObject, nmm:Photo; nie:url "/home/developer/Pictures/Image to send.jpg"nfo:width "120"; nfo:height "123" . }"

    What i do wrong?

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: How to index file by Tracker?

    OK,
    After hours i have such code

    void registerInTracker(QString fileName)
    {
    QSparqlConnection connection("QTRACKER");
    if (!connection.isValid())
    return;
    QString queryStr = "INSERT {_:1 a nfo:FileDataObject, nmm:Photo; nie:url \"";
    queryStr += fileName;
    queryStr += "\"; nfo:width \"120\"; nfo:height \"123\" . }";

    QSparqlQuery query(queryStr, QSparqlQuery::InsertStatement);
    QSparqlResult* result = connection.exec(query);
    if (!result->hasError())
    {
    result->waitForFinished();
    }
    }

    As result i have
    QTrackerResult: QSparqlError(6, "constraint failed (strerror of errno (not necessarily related): No such file or directory)", 4) "INSERT {_:1 a nfo:FileDataObject, nmm:Photo; nie:url "/home/developer/Pictures/MyFile.jpg"; nfo:width "120"; nfo:height "123" . }"

    I tried to insert my function before i create file and after - no result

    What is wrong?

  6. #6
    Registered User
    Join Date
    Nov 2011
    Posts
    2

    Re: How to index file by Tracker?

    Sorry, my mistake. You need to use "nieataObject" instead of "nfo:FileDataObject" and I think you will need also mimeType.

    I have tried this Sparql and it works:

    INSERT {
    _:1 a nieataObject, nmm:Photo;
    nie:url '/home/user/path/to/the/future/picture';
    nie:mimeType 'image/jpeg';
    nfo:width '120';
    nfo:height '123'.
    }

    You can use also bindings in your query, with a code like:

    QString queryStr = "INSERT { _:1 a nieataObject, nmm:Photo; nie:url ?ath; nfo:width ?:width ; nfo:height ?:height. }"
    QSparqlQuery query (queryStr, QSparqlQuery::InsertStatement);
    query.bindValue ("path", "/a/b/c");
    query.bindValue ("width", "120");
    query.bindValue ("height", "123");

    I didn't try this code, but It Should Work (TM)

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: How to index file by Tracker?

    Here is my new code

    QString queryStr = "INSERT {\n_:1 a nieataObject, nmm:Photo;\nnie:url ?ath;\nnie:mimeType ?:mime;\nnfo:width ?:width;\nnfo:height ?:height. }";

    QSparqlQuery query(queryStr, QSparqlQuery::InsertStatement);
    query.bindValue ("path", fileName);
    query.bindValue ("mime", "image/jpeg");
    query.bindValue ("width", "120");
    query.bindValue ("height", "123");

    QSparqlResult* result = connection.exec(query);
    if (!result->hasError())
    {
    result->waitForFinished();
    }
    if (result->hasError())
    {
    qDebug() << result->lastError().message();
    }

    And I still have "No such file or directory"
    May be this don't work in developer mode? Or something else?

  8. #8
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: How to index file by Tracker?

    Now after failure with QSparql i began to play with command line.
    No results..

    tracker-sparql -q "INSERT
    {_:1 a nie:DataObject,
    nmm:Photo;
    nie:url '/home/developer/MyDocs/Pictures/Sent.jpg';
    nie:mimeType 'image/jpeg';
    nfo:width '120';
    nfo:height '123'.
    }"
    returns:
    Could not run query, GDBus.Error:org.freedesktop.Tracker1.SparqlError.Parse: 1.1: syntax error, INSERT and DELETE are not supported in query mode


    tracker-sparql -q -u "INSERT
    {_:1 a nie:DataObject,
    nmm:Photo;
    nie:url '/home/developer/MyDocs/Pictures/Sent.jpg';
    nie:mimeType 'image/jpeg';
    nfo:width '120';
    nfo:height '123'.
    }"
    returns:
    Could not run query, GDBus.Error:org.freedesktop.Tracker1.SparqlError.Parse: 1.1: syntax error, expected SELECT or ASK

    What is wrong? Can anybody (except authors) work with tracker on N9?

  9. #9
    Registered User
    Join Date
    Dec 2004
    Posts
    27

    Re: How to index file by Tracker?

    Quote Originally Posted by mixasoft View Post
    As result i have
    QTrackerResult: QSparqlError(6, "constraint failed (strerror of errno (not necessarily related): No such file or directory)", 4) "INSERT {_:1 a nfo:FileDataObject, nmm:Photo; nie:url "/home/developer/Pictures/MyFile.jpg"; nfo:width "120"; nfo:height "123" . }"
    I have the same problem, and it seems to me that this error occurs when the item that is being inserted is already in the database. The insertion for me works the first time (but share UI is still not able to find the file after this)

  10. #10
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: How to index file by Tracker?

    Hi mixasoft,

    The error "No such file or directory" or "File not found" in share-ui are due to missing details inserted in the database for the saved image, try providing the modification date/time while inserting to database

    nie:contentCreated

    and bind it using -

    query.bindValue("contentCreated", QDateTime::currentDateTime().toString(Qt::ISODate));

  11. #11
    Registered User
    Join Date
    Dec 2004
    Posts
    27

    Re: How to index file by Tracker?

    Quote Originally Posted by kusumk View Post
    Hi mixasoft,

    The error "No such file or directory" or "File not found" in share-ui are due to missing details inserted in the database for the saved image, try providing the modification date/time while inserting to database

    nie:contentCreated

    and bind it using -

    query.bindValue("contentCreated", QDateTime::currentDateTime().toString(Qt::ISODate));
    The error reported here is reported by qsparql and occurs also if ShareUi is not invoked.

Similar Threads

  1. Increasing Size of Index file in Mail Folder
    By astroswanand in forum General Development Questions
    Replies: 1
    Last Post: 2008-07-09, 13:09
  2. Replies: 3
    Last Post: 2008-04-23, 18:24
  3. Problem with Index file
    By underground_demand in forum General Messaging
    Replies: 1
    Last Post: 2008-03-10, 08:14
  4. Damaged Index file in system\Mail catalogue
    By Bartex000 in forum General Messaging
    Replies: 0
    Last Post: 2006-10-18, 06:10
  5. Missing Index file in Mail folder: how can I get my saved messages back?
    By Ridley in forum General Development Questions
    Replies: 3
    Last Post: 2006-01-13, 13:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×