Esempio n. 1
0
    void Clipboard::_SetData(const ValueList& args, KValueRef result)
    {
        args.VerifyException("setData", "s s|o|l|0");

        std::string mimeType(args.GetString(0));
        DataType type = MimeTypeToDataType(mimeType);

        if (args.at(1)->IsNull() ||
            (args.at(1)->IsString() && !strcmp(args.at(1)->ToString(), "")))
        {
            this->ClearData(type);
        }
        else if (type == URI_LIST)
        {
            std::vector<std::string> uriList(ValueToURIList(args.at(1)));
            this->SetURIList(uriList);
        }
        else if (type == IMAGE)
        {
            BytesRef imageBytes(ValueToBytes(args.at(1)));
            this->SetImage(mimeType, imageBytes);
        }
        else
        {
            std::string newText(args.GetString(1, ""));
            this->SetText(newText);
        }
    }
String DataObjectGtk::url()
{
    Vector<KURL> uris(uriList());
    for (size_t i = 0; i < uris.size(); i++) {
        KURL& uri = uris[0];
        if (uri.isValid())
            return uri;
    }

    return String();
}
Vector<String> DataObjectGtk::files()
{
    Vector<KURL> uris(uriList());
    Vector<String> files;

    for (size_t i = 0; i < uris.size(); i++) {
        KURL& uri = uris[0];
        if (!uri.isValid() || !uri.isLocalFile())
            continue;

        files.append(uri.string());
    }

    return files;
}
Esempio n. 4
0
    void NotebooksTreeView::on_drag_data_received( const Glib::RefPtr<Gdk::DragContext> & context,
                                                   int x, int y,
                                                   const Gtk::SelectionData & selectionData,
                                                   guint , guint time_)
    {
      utils::UriList uriList(selectionData);
      if (uriList.size() == 0) {
        context->drag_finish (false, false, time_);
        return;
      }
      
      Gtk::TreePath treepath;
      Gtk::TreeViewDropPosition pos;
      if (get_dest_row_at_pos (x, y, treepath, pos) == false) {
        context->drag_finish (false, false, time_);
        return;
      }
      
      Gtk::TreeIter iter = get_model()->get_iter(treepath);
      if (!iter) {
        context->drag_finish (false, false, time_);
        return;
      }
      
      Notebook::Ptr destNotebook;
      iter->get_value(0, destNotebook);
      if(std::dynamic_pointer_cast<AllNotesNotebook>(destNotebook)) {
        context->drag_finish (false, false, time_);
        return;
      }

      for(utils::UriList::const_iterator uri_iter = uriList.begin();
          uri_iter != uriList.end(); ++uri_iter) {
        const sharp::Uri & uri(*uri_iter);
        NoteBase::Ptr note = m_note_manager.find_by_uri(uri.to_string());
        if (!note)
          continue;

        DBG_OUT ("Dropped into notebook: %s", note->get_title().c_str());

        destNotebook->add_note(std::static_pointer_cast<Note>(note));
      }

      context->drag_finish (true, false, time_);
    }
// -----------------------------------------------------------------------------
// CDrmUtilityCommon::GetOmaRightsStatusL
//
// -----------------------------------------------------------------------------
//
EXPORT_C DRM::TDrmRightsInfo DRM::CDrmUtilityCommon::GetOmaRightsStatusL(
    HBufC8*& aContentUri,
    ContentAccess::TIntent aIntent,
    CDRMConstraint* aConstraint )
    {
    CDRMPointerArray<CDRMPermission>* uriList( NULL );
    CDRMPointerArray<HBufC8>* individuals( NULL );
    RDRMClockClient clockClient;
    DRMClock::ESecurityLevel secLevel( DRMClock::KInsecure );
    TTime drmTime( Time::NullTTime() );
    TBool possiblefuture( EFalse );
    CDRMConstraint* constraint( NULL );
    CDRMConstraint* toplevel( NULL );
    TUint32 retval( 0 );
    TInt r( KErrNone );

    r = clockClient.Connect();
    CleanupClosePushL( clockClient );
    if ( !r )
        {
        TInt timeZone( 0 );
        clockClient.GetSecureTime( drmTime, timeZone, secLevel );
        }

    uriList = CDRMPointerArray<CDRMPermission>::NewLC();
    uriList->SetAutoCleanup( ETrue );
    TRAP_IGNORE( iOmaClient.GetDBEntriesL( *aContentUri, *uriList ) );

    if ( !uriList->Count() )
        {
        CleanupStack::PopAndDestroy( 2, &clockClient ); //clockClient, uriList
        return DRM::EURightsInfoMissing;
        }

    individuals = CDRMPointerArray<HBufC8>::NewLC();
    individuals->SetAutoCleanup( ETrue );
    TRAP_IGNORE( iOmaClient.GetSupportedIndividualsL( *individuals ) );

    // Now we have the time, rights and the individual constraints do the
    // checking. The rights are never valid if we get here so we don't have
    // to check for that
    for ( TInt i( 0 ); i < uriList->Count() && !possiblefuture ; i++ )
        {
        toplevel = NULL;
        constraint = NULL;

        // If the toplevel constraint is defined, get it:
        toplevel = (*uriList)[i]->TopLevelConstraint();
        // If constraint for the intent is defined, get it
        constraint = (*uriList)[i]->ConstraintForIntent( aIntent );

        // Top level constraint and constraint for intent, merge them
        if ( toplevel && constraint )
            {
            constraint->Merge( *toplevel );
            }
        // Only constraint for intent, use it
        else if ( constraint )
            {
            }
        // Only top level constraint or no constraints at all, continue
        else
            {
            continue;
            }

        // If the constraint is rejected due to non time reasons or there is no
        // time it can't be future
        constraint->Valid( drmTime, *individuals, retval );
        if ( retval & EConstraintCounter ||
             retval & EConstraintAccumulated ||
             retval & EConstraintTimedCounter ||
             retval & EConstraintIndividual ||
             retval & EConstraintNullDrmTime )
            {
            continue;
            }

        drmTime.HomeTime();

        // If the constrain has active start time and it is not valid,
        // it must be future
        if ( constraint->iActiveConstraints & EConstraintStartTime )
            {
            possiblefuture = ETrue;
            if ( aConstraint )
                {
                aConstraint->DuplicateL( *constraint );
                }
            }

        // If the constrain has active interval and it´s start time is in
        // future, it must be future
        else if ( constraint->iActiveConstraints & EConstraintInterval &&
                  constraint->iIntervalStart > drmTime )
            {
            possiblefuture = ETrue;
            if ( aConstraint )
                {
                aConstraint->DuplicateL( *constraint );
                }
            }
        } // End of for loop

    CleanupStack::PopAndDestroy( 3, &clockClient ); //individuals, urilist,
                                                    //clockClient
    return possiblefuture ? DRM::EURightsInfoFuture : DRM::EURightsInfoExpired;
    }