File indexing completed on 2024-12-22 04:57:04

0001 /*
0002     SPDX-FileCopyrightText: 2015-2019 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 class QString;
0010 #include <QList>
0011 
0012 extern const QString soapEnvNsUri;
0013 extern const QString ewsMsgNsUri;
0014 extern const QString ewsTypeNsUri;
0015 
0016 typedef enum {
0017     EwsFolderTypeMail = 0,
0018     EwsFolderTypeCalendar,
0019     EwsFolderTypeContacts,
0020     EwsFolderTypeSearch,
0021     EwsFolderTypeTasks,
0022     EwsFolderTypeUnknown,
0023 } EwsFolderType;
0024 
0025 typedef enum {
0026     EwsResponseSuccess = 0,
0027     EwsResponseWarning,
0028     EwsResponseError,
0029     EwsResponseParseError, // Internal - never returned by an Exchange server
0030     EwsResponseUnknown // Internal - never returned by an Exchange server
0031 } EwsResponseClass;
0032 
0033 typedef enum {
0034     EwsDIdCalendar = 0,
0035     EwsDIdContacts,
0036     EwsDIdDeletedItems,
0037     EwsDIdDrafts,
0038     EwsDIdInbox,
0039     EwsDIdJournal,
0040     EwsDIdNotes,
0041     EwsDIdOutbox,
0042     EwsDIdSentItems,
0043     EwsDIdTasks,
0044     EwsDIdMsgFolderRoot,
0045     EwsDIdRoot,
0046     EwsDIdJunkEmail,
0047     EwsDIdSearchFolders,
0048     EwsDIdVoiceMail,
0049     EwsDIdRecoverableItemsRoot,
0050     EwsDIdRecoverableItemsDeletions,
0051     EwsDIdRecoverableItemsVersions,
0052     EwsDIdRecoverableItemsPurges,
0053     EwsDIdArchiveRoot,
0054     EwsDIdArchiveMsgFolderRoot,
0055     EwsDIdArchiveDeletedItems,
0056     EwsDIdArchiveRecoverableItemsRoot,
0057     EwsDIdArchiveRecoverableItemsDeletions,
0058     EwsDIdArchiveRecoverableItemsVersions,
0059     EwsDIdArchiveRecoverableItemsPurges
0060 } EwsDistinguishedId;
0061 
0062 typedef enum { EwsShapeIdOnly = 0, EwsShapeDefault, EwsShapeAllProperties } EwsBaseShape;
0063 
0064 typedef enum {
0065     EwsPropSetMeeting = 0,
0066     EwsPropSetAppointment,
0067     EwsPropSetCommon,
0068     EwsPropSetPublicStrings,
0069     EwsPropSetAddress,
0070     EwsPropSetInternetHeaders,
0071     EwsPropSetCalendarAssistant,
0072     EwsPropSetUnifiedMessaging
0073 } EwsDistinguishedPropSetId;
0074 
0075 typedef enum {
0076     EwsPropTypeApplicationTime = 0,
0077     EwsPropTypeApplicationTimeArray,
0078     EwsPropTypeBinary,
0079     EwsPropTypeBinaryArray,
0080     EwsPropTypeBoolean,
0081     EwsPropTypeCLSID,
0082     EwsPropTypeCLSIDArray,
0083     EwsPropTypeCurrency,
0084     EwsPropTypeCurrencyArray,
0085     EwsPropTypeDouble,
0086     EwsPropTypeDoubleArray,
0087     EwsPropTypeError,
0088     EwsPropTypeFloat,
0089     EwsPropTypeFloatArray,
0090     EwsPropTypeInteger,
0091     EwsPropTypeTntegerArray,
0092     EwsPropTypeLong,
0093     EwsPropTypeLongArray,
0094     EwsPropTypeNull,
0095     EwsPropTypeObject,
0096     EwsPropTypeObjectArray,
0097     EwsPropTypeShort,
0098     EwsPropTypeShortArray,
0099     EwsPropTypeSystemTime,
0100     EwsPropTypeSystemTimeArray,
0101     EwsPropTypeString,
0102     EwsPropTypeStringArray
0103 } EwsPropertyType;
0104 
0105 typedef enum { EwsTraversalShallow = 0, EwsTraversalDeep, EwsTraversalSoftDeleted, EwsTraversalAssociated } EwsTraversalType;
0106 
0107 typedef enum {
0108     EwsItemTypeItem = 0,
0109     EwsItemTypeMessage,
0110     EwsItemTypeCalendarItem,
0111     EwsItemTypeContact,
0112     EwsItemTypeDistributionList,
0113     EwsItemTypeMeetingMessage,
0114     EwsItemTypeMeetingRequest,
0115     EwsItemTypeMeetingResponse,
0116     EwsItemTypeMeetingCancellation,
0117     EwsItemTypeTask,
0118     EwsItemTypeAbchPerson,
0119     EwsItemTypePostItem,
0120     EwsItemTypeUnknown
0121 } EwsItemType;
0122 
0123 typedef enum { EwsItemSensitivityNormal, EwsItemSensitivityPersonal, EwsItemSensitivityPrivate, EwsItemSensitivityConfidential } EwsItemSensitivity;
0124 
0125 /**
0126  *  @brief List of fields in EWS Item and its descendants
0127  *
0128  *  The list is based on the XSD schema and contains duplicates, which were commented out.
0129  */
0130 typedef enum {
0131     EwsItemFieldInvalid = -1,
0132 
0133     // Folder
0134     EwsFolderFieldFolderId,
0135     EwsFolderFieldParentFolderId,
0136     EwsFolderFieldFolderClass,
0137     EwsFolderFieldDisplayName,
0138     EwsFolderFieldTotalCount,
0139     EwsFolderFieldChildFolderCount,
0140     EwsFolderFieldManagedFolderInformation,
0141     EwsFolderFieldEffectiveRights,
0142     // Calendar folder
0143     EwsFolderFieldPermissionSet,
0144     // Contacts folder
0145     // EwsFolderFieldPermissionSet,          DUPLICATE
0146     // Mail folder
0147     EwsFolderFieldUnreadCount,
0148     // EwsFolderFieldPermissionSet,          DUPLICATE
0149     // Search folder
0150     // EwsFolderFieldUnreadCount,            DUPLICATE
0151     EwsFolderFieldSearchParameters,
0152     // Tasks folder
0153     // EwsFolderFieldUnreadCount,            DUPLICATE
0154 
0155     // Item
0156     EwsItemFieldMimeContent,
0157     EwsItemFieldItemId,
0158     EwsItemFieldParentFolderId,
0159     EwsItemFieldItemClass,
0160     EwsItemFieldSubject,
0161     EwsItemFieldSensitivity,
0162     EwsItemFieldBody,
0163     EwsItemFieldAttachments,
0164     EwsItemFieldDateTimeReceived,
0165     EwsItemFieldSize,
0166     EwsItemFieldCategories,
0167     EwsItemFieldImportance,
0168     EwsItemFieldInReplyTo,
0169     EwsItemFieldIsSubmitted,
0170     EwsItemFieldIsDraft,
0171     EwsItemFieldIsFromMe,
0172     EwsItemFieldIsResend,
0173     EwsItemFieldIsUnmodified,
0174     EwsItemFieldInternetMessageHeaders,
0175     EwsItemFieldDateTimeSent,
0176     EwsItemFieldDateTimeCreated,
0177     EwsItemFieldResponseObjects,
0178     EwsItemFieldReminderDueBy,
0179     EwsItemFieldReminderIsSet,
0180     EwsItemFieldReminderMinutesBeforeStart,
0181     EwsItemFieldDisplayCc,
0182     EwsItemFieldDisplayTo,
0183     EwsItemFieldHasAttachments,
0184     EwsItemFieldCulture,
0185     EwsItemFieldEffectiveRights,
0186     EwsItemFieldLastModifiedName,
0187     EwsItemFieldLastModifiedTime,
0188     EwsItemFieldIsAssociated,
0189     EwsItemFieldWebClientReadFormQueryString,
0190     EwsItemFieldWebClientEditFormQueryString,
0191     EwsItemFieldConversationId,
0192     EwsItemFieldUniqueBody,
0193     EwsItemFieldFlag,
0194     EwsItemFieldStoreEntryId,
0195     EwsItemFieldInstanceKey,
0196     EwsItemFieldNormalizedBody,
0197     EwsItemFieldEntityExtractionResult,
0198     EwsItemFieldPolicyTag,
0199     EwsItemFieldArchiveTag,
0200     EwsItemFieldRetentionDate,
0201     EwsItemFieldPreview,
0202     EwsItemFieldRightsManagementLicenseData,
0203     EwsItemFieldPredictedActionReasons,
0204     EwsItemFieldIsClutter,
0205     EwsItemFieldBlockStatus,
0206     EwsItemFieldHasBlockedImages,
0207     EwsItemFieldTextBody,
0208     EwsItemFieldIconIndex,
0209     EwsItemFieldSearchKey,
0210     EwsItemFieldSortKey,
0211     EwsItemFieldHashtags,
0212     EwsItemFieldMentions,
0213     EwsItemFieldMentionedMe,
0214     EwsItemFieldMentionsPreview,
0215     EwsItemFieldMentionsEx,
0216     EwsItemFieldAppliedHashtags,
0217     EwsItemFieldAppliedHashtagsPreview,
0218     EwsItemFieldLikes,
0219     EwsItemFieldLikesPreview,
0220     EwsItemFieldPendingSocialActivityTagIds,
0221     EwsItemFieldAtAllMention,
0222     EwsItemFieldCanDelete,
0223     EwsItemFieldInferenceClassification,
0224     // Message
0225     EwsItemFieldSender,
0226     EwsItemFieldToRecipients,
0227     EwsItemFieldCcRecipients,
0228     EwsItemFieldBccRecipients,
0229     EwsItemFieldIsReadReceiptRequested,
0230     EwsItemFieldIsDeliveryReceiptRequested,
0231     EwsItemFieldConversationIndex,
0232     EwsItemFieldConversationTopic,
0233     EwsItemFieldFrom,
0234     EwsItemFieldInternetMessageId,
0235     EwsItemFieldIsRead,
0236     EwsItemFieldIsResponseRequested,
0237     EwsItemFieldReferences,
0238     EwsItemFieldReplyTo,
0239     EwsItemFieldReceivedBy,
0240     EwsItemFieldReceivedRepresenting,
0241     // Task
0242     EwsItemFieldActualWork,
0243     EwsItemFieldAssignedTime,
0244     EwsItemFieldBillingInformation,
0245     EwsItemFieldChangeCount,
0246     EwsItemFieldCompanies,
0247     EwsItemFieldCompleteDate,
0248     EwsItemFieldContacts,
0249     EwsItemFieldDelegationState,
0250     EwsItemFieldDelegator,
0251     EwsItemFieldDueDate,
0252     EwsItemFieldIsAssignmentEditable,
0253     EwsItemFieldIsComplete,
0254     EwsItemFieldIsRecurring,
0255     EwsItemFieldIsTeamTask,
0256     EwsItemFieldMileage,
0257     EwsItemFieldOwner,
0258     EwsItemFieldPercentComplete,
0259     EwsItemFieldRecurrence,
0260     EwsItemFieldStartDate,
0261     EwsItemFieldStatus,
0262     EwsItemFieldStatusDescription,
0263     EwsItemFieldTotalWork,
0264     // Calendar
0265     EwsItemFieldUID,
0266     EwsItemFieldRecurrenceId,
0267     EwsItemFieldDateTimeStamp,
0268     EwsItemFieldStart,
0269     EwsItemFieldEnd,
0270     EwsItemFieldOriginalStart,
0271     EwsItemFieldIsAllDayEvent,
0272     EwsItemFieldLegacyFreeBusyStatus,
0273     EwsItemFieldLocation,
0274     EwsItemFieldWhen,
0275     EwsItemFieldIsMeeting,
0276     EwsItemFieldIsCancelled,
0277     // EwsItemFieldIsRecurring,              DUPLICATE
0278     EwsItemFieldMeetingRequestWasSent,
0279     // EwsItemFieldIsResponseRequested,      DUPLICATE
0280     EwsItemFieldCalendarItemType,
0281     EwsItemFieldMyResponseType,
0282     EwsItemFieldOrganizer,
0283     EwsItemFieldRequiredAttendees,
0284     EwsItemFieldOptionalAttendees,
0285     EwsItemFieldResources,
0286     EwsItemFieldConflictingMeetingCount,
0287     EwsItemFieldAdjacentMeetingCount,
0288     EwsItemFieldConflictingMeetings,
0289     EwsItemFieldAdjacentMeetings,
0290     EwsItemFieldDuration,
0291     EwsItemFieldTimeZone,
0292     EwsItemFieldStartTimeZone,
0293     EwsItemFieldEndTimeZone,
0294     EwsItemFieldAppointmentReplyTime,
0295     EwsItemFieldAppointmentSequenceNumber,
0296     EwsItemFieldAppointmentState,
0297     // EwsItemFieldRecurrence,               DUPLICATE
0298     EwsItemFieldFirstOccurrence,
0299     EwsItemFieldLastOccurrence,
0300     EwsItemFieldModifiedOccurrences,
0301     EwsItemFieldDeletedOccurrences,
0302     EwsItemFieldMeetingTimeZone,
0303     EwsItemFieldConferenceType,
0304     EwsItemFieldAllowNewTimeProposal,
0305     EwsItemFieldIsOnlineMeeting,
0306     EwsItemFieldMeetingWorkspaceUrl,
0307     EwsItemFieldNetShowUrl,
0308     EwsItemFieldEnhancedLocation,
0309     EwsItemFieldStartWallClock,
0310     EwsItemFieldEndWallClock,
0311     EwsItemFieldStartTimeZoneId,
0312     EwsItemFieldEndTimeZoneId,
0313     EwsItemFieldIntendedFreeBusyStatus,
0314     EwsItemFieldJoinOnlineMeetingUrl,
0315     EwsItemFieldOnlineMeetingSettings,
0316     EwsItemFieldIsOrganizer,
0317     EwsItemFieldCalendarActivityData,
0318     EwsItemFieldDoNotForwardMeeting,
0319     // MeetingMessage
0320     EwsItemFieldAssociatedCalendarItemId,
0321     EwsItemFieldIsDelegated,
0322     EwsItemFieldIsOutOfDate,
0323     EwsItemFieldHasBeenProcessed,
0324     EwsItemFieldResponseType,
0325     // EwsItemFieldUID,                      DUPLICATE
0326     // EwsItemFieldRecurrenceId,             DUPLICATE
0327     // EwsItemFieldDateTimeStamp,            DUPLICATE
0328     // MeetingRequestMessage
0329     EwsItemFieldMeetingRequestType,
0330     // EwsItemFieldIntendedFreeBusyStatus,   DUPLICATE
0331     // EwsItemFieldStart,                    DUPLICATE
0332     // EwsItemFieldEnd,                      DUPLICATE
0333     // EwsItemFieldOriginalStart,            DUPLICATE
0334     // EwsItemFieldIsAllDayEvent,            DUPLICATE
0335     // EwsItemFieldLegacyFreeBusyStatus,     DUPLICATE
0336     // EwsItemFieldLocation,                 DUPLICATE
0337     // EwsItemFieldWhen,                     DUPLICATE
0338     // EwsItemFieldIsMeeting,                DUPLICATE
0339     // EwsItemFieldIsCancelled,              DUPLICATE
0340     // EwsItemFieldIsRecurring,              DUPLICATE
0341     // EwsItemFieldMeetingRequestWasSent,    DUPLICATE
0342     // EwsItemFieldCalendarItemType,         DUPLICATE
0343     // EwsItemFieldMyResponseType,           DUPLICATE
0344     // EwsItemFieldOrganizer,                DUPLICATE
0345     // EwsItemFieldRequiredAttendees,        DUPLICATE
0346     // EwsItemFieldOptionalAttendees,        DUPLICATE
0347     // EwsItemFieldResources,                DUPLICATE
0348     // EwsItemFieldConflictingMeetingCount,  DUPLICATE
0349     // EwsItemFieldAdjacentMeetingCount,     DUPLICATE
0350     // EwsItemFieldConflictingMeetings,      DUPLICATE
0351     // EwsItemFieldAdjacentMeetings,         DUPLICATE
0352     // EwsItemFieldDuration,                 DUPLICATE
0353     // EwsItemFieldTimeZone,                 DUPLICATE
0354     // EwsItemFieldAppointmentReplyTime,     DUPLICATE
0355     // EwsItemFieldAppointmentSequenceNumber,DUPLICATE
0356     // EwsItemFieldAppointmentState,         DUPLICATE
0357     // EwsItemFieldRecurrence,               DUPLICATE
0358     // EwsItemFieldFirstOccurrence,          DUPLICATE
0359     // EwsItemFieldLastOccurrence,           DUPLICATE
0360     // EwsItemFieldModifiedOccurrences,      DUPLICATE
0361     // EwsItemFieldDeletedOccurrences,       DUPLICATE
0362     // EwsItemFieldMeetingTimeZone,          DUPLICATE
0363     // EwsItemFieldConferenceType,           DUPLICATE
0364     // EwsItemFieldAllowNewTimeProposal,     DUPLICATE
0365     // EwsItemFieldIsOnlineMeeting,          DUPLICATE
0366     // EwsItemFieldMeetingWorkspaceUrl,      DUPLICATE
0367     // EwsItemFieldNetShowUrl,               DUPLICATE
0368     // Contact
0369     EwsItemFieldFileAs,
0370     EwsItemFieldFileAsMapping,
0371     EwsItemFieldDisplayName,
0372     EwsItemFieldGivenName,
0373     EwsItemFieldInitials,
0374     EwsItemFieldMiddleName,
0375     EwsItemFieldNickname,
0376     EwsItemFieldCompleteName,
0377     EwsItemFieldCompanyName,
0378     EwsItemFieldEmailAddresses,
0379     EwsItemFieldPhysicalAddresses,
0380     EwsItemFieldPhoneNumbers,
0381     EwsItemFieldAssistantName,
0382     EwsItemFieldBirthday,
0383     EwsItemFieldBusinessHomePage,
0384     EwsItemFieldChildren,
0385     // EwsItemFieldCompanies,                DUPLICATE
0386     EwsItemFieldContactSource,
0387     EwsItemFieldDepartment,
0388     EwsItemFieldGeneration,
0389     EwsItemFieldImAddresses,
0390     EwsItemFieldJobTitle,
0391     EwsItemFieldManager,
0392     // EwsItemFieldMileage,                  DUPLICATE
0393     EwsItemFieldOfficeLocation,
0394     EwsItemFieldPostalAddressIndex,
0395     EwsItemFieldProfession,
0396     EwsItemFieldSpouseName,
0397     EwsItemFieldSurname,
0398     EwsItemFieldWeddingAnniversary,
0399     // DistributionList
0400     // EwsItemFieldDisplayName,              DUPLICATE
0401     // EwsItemFieldFileAs,                   DUPLICATE
0402     // EwsItemFieldContactSource,            DUPLICATE
0403     // Additional fields not in EWS specification
0404     EwsItemFieldBodyIsHtml,
0405     EwsItemFieldExtendedProperties,
0406     EwsItemFieldExchangePersonIdGuid,
0407 } EwsItemFields;
0408 
0409 typedef enum { EwsItemImportanceLow, EwsItemImportanceNormal, EwsItemImportanceHigh } EwsItemImportance;
0410 
0411 typedef enum { EwsBasePointBeginning, EwsBasePointEnd } EwsIndexedViewBasePoint;
0412 
0413 typedef enum { EwsCalendarItemSingle = 0, EwsCalendarItemOccurrence, EwsCalendarItemException, EwsCalendarItemRecurringMaster } EwsCalendarItemType;
0414 
0415 typedef enum {
0416     EwsEventResponseUnknown = 0,
0417     EwsEventResponseOrganizer,
0418     EwsEventResponseTentative,
0419     EwsEventResponseAccept,
0420     EwsEventResponseDecline,
0421     EwsEventResponseNotReceived
0422 } EwsEventResponseType;
0423 
0424 typedef enum { EwsLfbStatusFree = 0, EwsLfbStatusTentative, EwsLfbStatusBusy, EwsLfbOutOfOffice, EwsLfbNoData } EwsLegacyFreeBusyStatus;
0425 
0426 typedef enum {
0427     EwsDispSaveOnly = 0,
0428     EwsDispSendOnly,
0429     EwsDispSendAndSaveCopy,
0430 } EwsMessageDisposition;
0431 
0432 typedef enum {
0433     EwsResolNeverOverwrite = 0,
0434     EwsResolAutoResolve,
0435     EwsResolAlwaysOverwrite,
0436 } EwsConflictResolution;
0437 
0438 typedef enum {
0439     EwsMeetingDispSendToNone = 0,
0440     EwsMeetingDispSendOnlyToAll,
0441     EwsMeetingDispSendOnlyToChanged,
0442     EwsMeetingDispSendToAllAndSaveCopy,
0443     EwsMeetingDispSendToChangedAndSaveCopy,
0444     EwsMeetingDispUnspecified
0445 } EwsMeetingDisposition;
0446 
0447 typedef enum {
0448     EwsCopiedEvent = 0,
0449     EwsCreatedEvent,
0450     EwsDeletedEvent,
0451     EwsModifiedEvent,
0452     EwsMovedEvent,
0453     EwsNewMailEvent,
0454     EwsFreeBusyChangedEvent,
0455     EwsStatusEvent,
0456     EwsUnknownEvent
0457 } EwsEventType;
0458 
0459 typedef enum {
0460     EwsResponseCodeNoError = 0,
0461     EwsResponseCodeErrorServerBusy,
0462     EwsResponseCodeUnauthorized,
0463     EwsResponseCodeUnknown,
0464 } EwsResponseCode;
0465 
0466 template<typename T>
0467 T decodeEnumString(const QString &str, const QString *table, unsigned count, bool *ok)
0468 {
0469     unsigned i;
0470     T enumVal = T();
0471     for (i = 0; i < count; i++) {
0472         if (str == table[i]) {
0473             enumVal = static_cast<T>(i);
0474             break;
0475         }
0476     }
0477     *ok = (i < count);
0478     return enumVal;
0479 }
0480 
0481 inline bool isEwsMessageItemType(EwsItemType type)
0482 {
0483     return (type == EwsItemTypeItem) || (type == EwsItemTypePostItem);
0484 }
0485 
0486 extern const QList<QString> ewsItemTypeNames;
0487 
0488 EwsResponseCode decodeEwsResponseCode(const QString &code);
0489 bool isEwsResponseCodeTemporaryError(EwsResponseCode code);