void Media::setImage(const std::shared_ptr<Image>& image, Dbo::Transaction& transaction) const { transaction.session().execute( "DELETE FROM media_attachment WHERE media_id = ? AND type = 'preview'" ).bind( uid() ); MediaAttachment *fullAttachment = MediaAttachment::image("full", uid(), *image ); MediaAttachment *thumbnailAttachment = MediaAttachment::image("thumbnail", uid(), *image->scaled(IMAGE_SIZE_THUMB, 60)); MediaAttachment *playerAttachment = MediaAttachment::image("player", uid(), *image->scaled(IMAGE_SIZE_PLAYER) ); transaction.session().add( fullAttachment ); transaction.session().add( thumbnailAttachment ); transaction.session().add( playerAttachment ); }
WString Media::title(Dbo::Transaction& transaction) const { MediaPropertiesPtr properties = transaction.session().find<MediaProperties>().where("media_id = ?").bind(uid()); if(!properties || properties->title().empty()) return WString::fromUTF8(filename()); return WString::fromUTF8(properties->title()); }
void SessionInfo::endStale(Dbo::Transaction& transaction) { transaction.session().execute("UPDATE session_info SET session_ended = ? WHERE session_id <> ? AND session_ended IS NULL") .bind(WDateTime::currentDateTime().toPosixTime()) .bind(wApp->sessionId()) ; }
Dbo::ptr< MediaAttachment > Media::preview(Dbo::Transaction& transaction, Media::PreviewSize size ) const { string previewSize; switch(size) { case Media::PreviewFull: previewSize="full"; break; case Media::PreviewPlayer: previewSize="player"; break; case Media::PreviewThumb: previewSize="thumbnail"; break; } return transaction.session().find<MediaAttachment>().where("media_id = ? AND type = 'preview' AND name = ?") .bind(uid()).bind(previewSize); }
MediaPropertiesPtr Media::properties(Dbo::Transaction& transaction) const { return transaction.session().find<MediaProperties>().where("media_id = ?").bind(uid()).resultValue(); }
long Media::subtitles_count(Dbo::Transaction& transaction) const { return transaction.session().query<long>("select count(*) from media_attachment").where("media_id = ? AND type = 'subtitles'").bind(uid()).resultValue(); }
Dbo::collection<MediaAttachmentPtr> Media::subtitles(Dbo::Transaction& transaction) const { return transaction.session().find<MediaAttachment>().where("media_id = ? AND type = 'subtitles'").bind(uid()).resultList(); }