Create a new resource and add it to the database
| 2576 | |
| 2577 | // Create a new resource and add it to the database |
| 2578 | qint32 NBrowserWindow::createResource(Resource &r, int sequence, QByteArray data, QString mime, bool attachment, QString filename) { |
| 2579 | ConfigStore cs(global.db); |
| 2580 | qint32 rlid = cs.incrementLidCounter(); |
| 2581 | |
| 2582 | QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5); |
| 2583 | |
| 2584 | QString guid = QString::number(rlid); |
| 2585 | NoteTable noteTable(global.db); |
| 2586 | r.guid = guid; |
| 2587 | r.noteGuid = noteTable.getGuid(lid); |
| 2588 | QString noteguid = r.noteGuid; |
| 2589 | if (noteguid == "") |
| 2590 | return 0; |
| 2591 | r.mime = mime; |
| 2592 | r.active = true; |
| 2593 | r.updateSequenceNum = sequence; |
| 2594 | r.width = 0; |
| 2595 | r.height = 0; |
| 2596 | r.duration = 0; |
| 2597 | ResourceAttributes a; |
| 2598 | if (r.attributes.isSet()) |
| 2599 | a = r.attributes; |
| 2600 | a.attachment = attachment; |
| 2601 | if (filename != "") { |
| 2602 | a.fileName = filename; |
| 2603 | } |
| 2604 | |
| 2605 | Data d; |
| 2606 | d.body = data; |
| 2607 | d.bodyHash = hash; |
| 2608 | d.size = data.size(); |
| 2609 | |
| 2610 | r.data = d; |
| 2611 | r.attributes = a; |
| 2612 | ResourceTable resourceTable(global.db); |
| 2613 | resourceTable.add(rlid, r, true, lid); |
| 2614 | |
| 2615 | return rlid; |
| 2616 | } |
| 2617 | |
| 2618 | |
| 2619 |
nothing calls this directly
no test coverage detected