Esempio n. 1
0
  static void processParameters(final ParameterList icparams, final BasePropertyType prop)
      throws Throwable {
    if ((icparams == null) || icparams.isEmpty()) {
      return;
    }

    final Iterator it = icparams.iterator();

    while (it.hasNext()) {
      final Parameter param = (Parameter) it.next();

      final ParameterInfoIndex pii = ParameterInfoIndex.lookupPname(param.getName());

      if (pii == null) {
        continue;
      }

      final JAXBElement<? extends BaseParameterType> xmlprop = doParameter(param, pii);

      if (xmlprop != null) {
        if (prop.getParameters() == null) {
          prop.setParameters(new ArrayOfParameters());
        }

        prop.getParameters().getBaseParameter().add(xmlprop);
      }
    }
  }
Esempio n. 2
0
  /**
   * Test to ensure that EXDATE properties are correctly applied.
   *
   * @throws ParseException
   */
  public void testGetConsumedTimeWithExDate() throws ParseException {

    VEvent event1 = new VEvent(new DateTime("20050103T080000"), new Dur(0, 0, 15, 0), "Event 1");

    Recur rRuleRecur = new Recur("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR");
    RRule rRule = new RRule(rRuleRecur);
    event1.getProperties().add(rRule);

    ParameterList parameterList = new ParameterList();
    parameterList.add(Value.DATE);
    ExDate exDate = new ExDate(parameterList, "20050106");
    event1.getProperties().add(exDate);

    Date start = new Date("20050106");
    Date end = new Date("20050107");
    PeriodList list = event1.getConsumedTime(start, end);
    assertTrue(list.isEmpty());
  }
Esempio n. 3
0
  void populateAttendees(Event e) throws RemoteException {
    Uri attendeesUri =
        Attendees.CONTENT_URI
            .buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
            .build();
    @Cleanup
    Cursor c =
        providerClient.query(
            attendeesUri,
            new String[] {
              /* 0 */ Attendees.ATTENDEE_EMAIL,
              Attendees.ATTENDEE_NAME,
              Attendees.ATTENDEE_TYPE,
              /* 3 */ Attendees.ATTENDEE_RELATIONSHIP,
              Attendees.STATUS
            },
            Attendees.EVENT_ID + "=?",
            new String[] {String.valueOf(e.getLocalID())},
            null);
    while (c != null && c.moveToNext()) {
      try {
        Attendee attendee = new Attendee(new URI("mailto", c.getString(0), null));
        ParameterList params = attendee.getParameters();

        String cn = c.getString(1);
        if (cn != null) params.add(new Cn(cn));

        // type
        int type = c.getInt(2);
        params.add((type == Attendees.TYPE_RESOURCE) ? CuType.RESOURCE : CuType.INDIVIDUAL);

        // role
        int relationship = c.getInt(3);
        switch (relationship) {
          case Attendees.RELATIONSHIP_ORGANIZER:
            params.add(Role.CHAIR);
            break;
          case Attendees.RELATIONSHIP_ATTENDEE:
          case Attendees.RELATIONSHIP_PERFORMER:
          case Attendees.RELATIONSHIP_SPEAKER:
            params.add(
                (type == Attendees.TYPE_REQUIRED) ? Role.REQ_PARTICIPANT : Role.OPT_PARTICIPANT);
            break;
          case Attendees.RELATIONSHIP_NONE:
            params.add(Role.NON_PARTICIPANT);
        }

        // status
        switch (c.getInt(4)) {
          case Attendees.ATTENDEE_STATUS_INVITED:
            params.add(PartStat.NEEDS_ACTION);
            break;
          case Attendees.ATTENDEE_STATUS_ACCEPTED:
            params.add(PartStat.ACCEPTED);
            break;
          case Attendees.ATTENDEE_STATUS_DECLINED:
            params.add(PartStat.DECLINED);
            break;
          case Attendees.ATTENDEE_STATUS_TENTATIVE:
            params.add(PartStat.TENTATIVE);
            break;
        }

        e.addAttendee(attendee);
      } catch (URISyntaxException ex) {
        Log.e(TAG, "Couldn't parse attendee information, ignoring", ex);
      }
    }
  }