void RocketStorageSelectionDialog::OnItemDoubleClicked(QListWidgetItem *item) { MeshmoonStorageItemWidget *storageItem = dynamic_cast<MeshmoonStorageItemWidget*>(item); if (!storageItem) return; if (storageItem->data.isDir) { if (storageItem->data.key != "..") { MeshmoonStorageItem folder(storageItem, storage_); OpenFolder(folder); } else if (currentFolder_ && currentFolder_->parent) { MeshmoonStorageItem folder(currentFolder_->parent, storage_); OpenFolder(folder); } } else { item_ = MeshmoonStorageItem(storageItem, storage_); OnSelect(); } }
void LoadDefaultTabs () { InOut log (_T("LoadDefaultTabs")); CString lastFolder; DisableSync(); switch (gOptions.m_OnStart) { case ONSTART_NOTHING: break; case ONSTART_MYCOMP: OpenFolder (CONST_MYCOMPUTER); break; case ONSTART_LASTSAVED: for (unsigned int i = 0 ; i < gOptions.m_LastTabs.size (); i++) //if (IsDirectory (gOptions.m_LastTabs[i].m_Name)) { SureBackSlashEx (gOptions.m_LastTabs[i].m_Name); OpenFolder (gOptions.m_LastTabs[i].m_Name); lastFolder = gOptions.m_LastTabs[i].m_Name; } if (!gOptions.m_LastTabsActiveView.IsEmpty()) lastFolder = gOptions.m_LastTabsActiveView; break; case ONSTART_DEFAULT: for (unsigned int i = 0 ; i < gOptions.m_DefaultTabs.size (); i++) { SureBackSlashEx (gOptions.m_DefaultTabs[i].m_Name); OpenFolder (gOptions.m_DefaultTabs[i].m_Name); lastFolder = gOptions.m_DefaultTabs[i].m_Name; } break; } EnableSync(); if (!lastFolder.IsEmpty()) { SureBackSlashEx (lastFolder); OpenFolder (lastFolder); SyncUI (lastFolder); } }
int cXdg::OpenFolderHighlightFile(const std::string& sFilePathUTF8) { // Nautilus does a better job of this than xdg-open so we try to use that where possible if (IsDesktopGnome()) return system(("nautilus \"" + sFilePathUTF8 + "\"").c_str()); return OpenFolder(sFilePathUTF8); }
static void OpenMusicPackDir(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) { if (!OpenFolder(music_pack_path)) { TXT_MessageBox("Error", "Failed to open music pack directory."); } }
LRESULT PreviousImagesView::OnPrevImagesOpenFolder(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if (m_spCurrentImage != nullptr) OpenFolder(m_spCurrentImage->Filename()); return 0; }
int CFSReg::Read(const CFSString &szPath, CFSData *pData, DWORD *pdwDataType) { HKEY hRoot; CFSString szFolder; CFSString szFile; if (Split(szPath, &hRoot, &szFolder, &szFile)!=0) { return -1; } HKEY hKey; if ((hKey=OpenFolder(hRoot, szFolder))==0) { return -1; } DWORD dwDataLen=0; if (RegQueryValueEx(hKey, szFile, 0, pdwDataType, NULL, &dwDataLen)!=ERROR_SUCCESS) { RegCloseKey(hKey); return -1; } pData->SetSize(dwDataLen); if (RegQueryValueEx(hKey, szFile, 0, pdwDataType, (BYTE *)pData->GetData(), &dwDataLen)!=ERROR_SUCCESS) { RegCloseKey(hKey); return -1; } RegCloseKey(hKey); if (dwDataLen!=(DWORD)pData->GetSize()) { return -1; } return 0; }
CMAPIFolder* CMAPIEx::OpenInbox(BOOL bInternal) { #ifdef _WIN32_WCE return OpenFolder(PR_CE_IPM_INBOX_ENTRYID, bInternal); #else if(!m_pMsgStore) return NULL; ULONG cbEntryID; LPENTRYID pEntryID; DWORD dwObjType; LPMAPIFOLDER pFolder; if(m_pMsgStore->GetReceiveFolder(NULL, 0, &cbEntryID, &pEntryID, NULL)!=S_OK) return NULL; HRESULT hr=m_pMsgStore->OpenEntry(cbEntryID, pEntryID, NULL, m_ulMDBFlags, &dwObjType, (LPUNKNOWN*)&pFolder); MAPIFreeBuffer(pEntryID); if(hr==S_OK && pFolder) { CMAPIFolder* pMAPIFolder=new CMAPIFolder(this, pFolder); if(bInternal) { delete m_pFolder; m_pFolder=pMAPIFolder; } return pMAPIFolder; } return NULL; #endif }
void InfoStrView::MouseDown (BPoint where) { /* Detect double-click */ BMessage* msg = Window()->CurrentMessage(); int32 clicks = msg->FindInt32 ("clicks"); int32 button = msg->FindInt32 ("buttons"); static BPoint previousPoint = where; if ((button == lastButton) && (clicks > 1)) clickCount++; else clickCount = 1; lastButton = button; /* Make sure the two clicks are clicked close to eachother (5 pixel tolerance) */ if (clickCount >= 2 && button == B_PRIMARY_MOUSE_BUTTON && itemPath != NULL && ((where.y >= previousPoint.y - 5 && where.y <= previousPoint.y + 5) && where.x >= previousPoint.x - 5 && where.x <= previousPoint.x + 5)) { DrawOpenAnimation (CalcAnimationRect (where)); OpenFolder (itemPath); } previousPoint = where; BStringView::MouseDown (where); }
void FileListBox::PopulateFileList(const std::string& path) { new_path = path; if (path.compare(path.size()-1, sizeof(PATH_SEPARATOR), PATH_SEPARATOR)) new_path += PATH_SEPARATOR; MSG_DEBUG("file", "Searching in %s\n", new_path.c_str()); FolderSearch *f = OpenFolder(new_path); // Now that we have made use of new_path, it can be freed: // clearing the list is now possible Clear(); if (f) { bool is_file = list_files; const char *name; while ((name = FolderSearchNext(f, is_file)) != NULL) { if (is_file) { // We have a file, check that it validates the list if (MatchFilter(name)) { std::string* filename = new std::string(new_path); *filename += name; MSG_DEBUG("file", "Adding file %s\n", name); AddLabelItem(false, ANSIToUTF8(new_path, name), filename, Font::FONT_MEDIUM); } else { MSG_DEBUG("file", "NOT adding file %s, invalid extension\n", name); } } else if (strcmp(name, ".")) { std::string* filename; if (!strcmp(name, "..")) { // Are we at the root? if (!strcmp(name, PATH_SEPARATOR)) break; size_t pos = new_path.find_last_of(PATH_SEPARATOR, new_path.size()-2, sizeof(PATH_SEPARATOR)); filename = new std::string(new_path.substr(0, pos+1)); } else filename = new std::string(new_path); *filename += name; MSG_DEBUG("file", "Adding directory %s\n", name); AddLabelItem(false, std::string("[") + ANSIToUTF8(new_path, name) + "]", filename, Font::FONT_MEDIUM, Font::FONT_NORMAL, c_yellow); } else MSG_DEBUG("file", "Rejecting %s\n", name); // Prepare again for searching files is_file = list_files; } CloseFolder(f); Pack(); NeedRedrawing(); } else { MSG_DEBUG("file", "Search failed?\n"); } // Store last time to drop fast clicks last_time = SDL_GetTicks(); }
void RocketStorageSelectionDialog::OnStorageAuthCompleted() { // If the start directory is null then we know we can default it to the storage root. if (startDirectory_.IsNull()) startDirectory_ = storage_->RootDirectory(); OpenFolder(startDirectory_); }
CMAPIFolder* CMAPIEx::OpenDrafts(BOOL bInternal) { #ifdef _WIN32_WCE return OpenFolder(PR_CE_IPM_DRAFTS_ENTRYID, bInternal); #else return OpenSpecialFolder(PR_IPM_DRAFTS_ENTRYID, bInternal); #endif }
// Static method std::vector<std::pair<std::string, std::string> > GameMode::ListGameModes() { std::vector<std::pair<std::string, std::string> > game_modes; game_modes.push_back(std::pair<std::string, std::string>("classic", _("Classic"))); game_modes.push_back(std::pair<std::string, std::string>("unlimited", _("Unlimited"))); game_modes.push_back(std::pair<std::string, std::string>("blitz", _("Blitz"))); #ifdef DEBUG game_modes.push_back(std::pair<std::string, std::string>("skin_viewer", "Skin Viewer")); #endif std::string personal_dir = Config::GetInstance()->GetPersonalDataDir() + std::string("game_mode" PATH_SEPARATOR); FolderSearch *f = OpenFolder(personal_dir); if (f) { bool is_file = true; const char *name; while ((name = FolderSearchNext(f, is_file)) != NULL) { // Only check files if (is_file) { std::string filename(name); if (filename.size() >= 5 && filename.compare(filename.size()-4, 4, ".xml") == 0 && (filename.size() < 12 || filename.compare(filename.size()-12, 12, "_objects.xml") != 0)) { std::string game_mode_name = filename.substr(0, filename.size()-4); game_modes.push_back(std::pair<std::string, std::string>(game_mode_name, game_mode_name)); } } // Prepare again for searching files is_file = true; } CloseFolder(f); } return game_modes; }
BOOL CSourceDirListCtrl::OnCommand(WPARAM wParam, LPARAM lParam) { switch(wParam) { case IDM_SOURCE_DIR_REMOVE: { RemoveSelectedItems(); } break; case IDM_SOURCE_DIR_REMOVE_ALL: { DeleteAllItems(); SetHeaderCheckedState(0, CL_UNCHECKED); m_HeaderCtrl.UpdateWindow(); } break; case IDM_SOURCE_DIR_SELECT_ALL: { SelectAllItems(); } break; case IDM_SOURCE_DIR_CHECK: { CheckSelectedItems(TRUE); } break; case IDM_SOURCE_DIR_UNCHECK: { CheckSelectedItems(FALSE); } break; case IDM_SOURCE_DIR_OPEN_DIR: { OpenFolder(); } break; } return CCheckListCtrl::OnCommand(wParam, lParam); }
GPlainTextLoggerWidget::GPlainTextLoggerWidget(GPlainTextLogger* pPlainTextLogger, QWidget *parent /*= 0*/) : QWidget(parent) , m_pLogger(pPlainTextLogger) { setupUi(this); if(!m_pLogger) return; connect(pButtonFolder, SIGNAL(clicked()), m_pLogger, SLOT(ChooseFolder())); connect(m_pOpenLogFileButton, SIGNAL(clicked()), m_pLogger, SLOT(OpenLogFile())); connect(m_pOpenFolderButton, SIGNAL(clicked()), m_pLogger, SLOT(OpenFolder())); connect(m_pTrashContentButton, SIGNAL(clicked()), m_pLogger, SLOT(TrashContent())); // connect(pSettingsButton, SIGNAL(clicked()), m_pLogger, SLOT(ShowExtraSettingsWidget())); pFolderLayout->addWidget(m_pLogger->m_FolderPath.ProvideNewLabel(this)); pFolderLayout->addWidget(m_pLogger->m_FolderPath.ProvideNewParamLineEdit(this)); pFolderFileLayout->addRow(m_pLogger->m_FileName.ProvideNewLabel(this), m_pLogger->m_FileName.ProvideNewParamLineEdit(this)); pUpdateLayout->addWidget(m_pLogger->m_ShouldLogOnTimer.ProvideNewParamCheckBox(this)); pUpdateLayout->addWidget(m_pLogger->m_SecondTimer.ProvideNewLabel(this)); pUpdateLayout->addWidget(m_pLogger->m_SecondTimer.ProvideNewParamSpinBox(this)); pUpdateLayout->addStretch(); pUpdateLayout->addWidget(m_pLogger->m_ShouldLogOnUpdate.ProvideNewParamCheckBox(this)); pBucketLayout->addWidget(m_pLogger->m_Bucket.ProvideNewParamWidget(this)); pBucketLayout->addWidget(m_pLogger->m_BucketColNames.ProvideParamBucketWidget(this, Qt::Horizontal)); pFirstColLayout1->addWidget(m_pLogger->m_CurrentIndexUpdate.ProvideNewLabel(this)); pFirstColLayout1->addWidget(m_pLogger->m_CurrentIndexUpdate.ProvideNewParamWidget(this)); pFirstColLayout1->addWidget(m_pLogger->m_SecUpdate.ProvideNewLabel(this)); pFirstColLayout1->addWidget(m_pLogger->m_SecUpdate.ProvideNewParamWidget(this)); pFirstColLayout1->addStretch(); //pFirstColLayout1->addWidget(m_pLogger->m_FirstColName.ProvideNewLabel(this)); //pFirstColLayout1->addWidget(m_pLogger->m_FirstColName.ProvideNewParamLineEdit(this)); //pFirstColLayout2->addWidget(m_pLogger->m_FirstColFormula.ProvideNewLabel(this)); //pFirstColLayout2->addWidget(m_pLogger->m_FirstColFormula.ProvideNewParamLineEdit(this)); //pFirstColLayout2->addWidget(m_pLogger->m_FirstColValue.ProvideNewLabel(this)); //pFirstColLayout2->addWidget(m_pLogger->m_FirstColValue.ProvideNewParamWidget(this)); }
LPMAPIFOLDER CMAPIEx::OpenInbox(BOOL bInternal) { if (!m_pMsgStore) return NULL; #ifdef _WIN32_WCE return OpenFolder(PR_CE_IPM_INBOX_ENTRYID); #else ULONG cbEntryID; LPENTRYID pEntryID; DWORD dwObjType; LPMAPIFOLDER pFolder; if (m_pMsgStore->GetReceiveFolder(NULL, 0, &cbEntryID, &pEntryID, NULL) != S_OK) return NULL; m_pMsgStore->OpenEntry(cbEntryID, pEntryID, NULL, m_ulMDBFlags, &dwObjType, (LPUNKNOWN *)&pFolder); MAPIFreeBuffer(pEntryID); #endif if (pFolder && bInternal) { RELEASE(m_pFolder); m_pFolder = pFolder; } return pFolder; }
void CustomTeamsList::LoadList() { Clear(); const Config *config = Config::GetInstance(); // Load personal custom teams std::string dirname = config->GetPersonalConfigDir() + "custom_team" + PATH_SEPARATOR; FolderSearch *f = OpenFolder(dirname); if (f) { bool search_files = false; const char *name; while ((name = FolderSearchNext(f, search_files)) != NULL) LoadOneTeam(dirname, name); CloseFolder(f); } else { std::cerr << std::endl << Format(_("Cannot open the custom teams directory (%s)!"), dirname.c_str()) << std::endl; } Sort(); }
static bool messages_dump(TALLOC_CTX *mem_ctx, mapi_object_t *obj_store, mapi_object_t *parent, struct mbox_tree_item *folder, struct mbox_data *mdata, const char *base_path) { enum MAPISTATUS retval; int ret; mapi_object_t obj_folder; mapi_object_t obj_message; char *filename = NULL; struct mapi_SPropValue_array lpProps; uint32_t context_id; mapi_object_t obj_htable; struct SPropTagArray *SPropTagArray; struct SRowSet SRowSet; uint32_t i; uint32_t count; const uint64_t *fid; const uint64_t *mid; const uint32_t *size; const char *class; struct SPropValue *lpProp; /* Search the folder from Top Information Store */ mapi_object_init(&obj_folder); retval = OpenFolder(parent, folder->id, &obj_folder); if (retval != MAPI_E_SUCCESS) return false; /* Get container class */ SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_CONTAINER_CLASS); retval = GetProps(&obj_folder, MAPI_UNICODE, SPropTagArray, &lpProp, &count); MAPIFreeBuffer(SPropTagArray); if ((lpProp[0].ulPropTag != PR_CONTAINER_CLASS) || (retval != MAPI_E_SUCCESS)) { class = IPF_NOTE; } else {
CMAPIFolder* CMAPIEx::OpenJunkFolder(BOOL bInternal) { return OpenFolder(_T("Junk E-mail"), bInternal); }
FileSyst::FileSyst(){ CoInitialize(NULL); root = OpenFolder(); //Create vector of fileNames from directory TransverseDirectory(root,directories); }
CMAPIFolder* CMAPIEx::OpenDeletedItems(BOOL bInternal) { return OpenFolder(PR_IPM_WASTEBASKET_ENTRYID, bInternal); }
CMAPIFolder* CMAPIEx::OpenSentItems(BOOL bInternal) { return OpenFolder(PR_IPM_SENTMAIL_ENTRYID, bInternal); }
CMAPIFolder* CMAPIEx::OpenOutbox(BOOL bInternal) { return OpenFolder(PR_IPM_OUTBOX_ENTRYID, bInternal); }
/** \details Test #1804 ModifyRecipients and try to build RecipientRow with multi-value properties (e.g. PidTagUserX509Certificate) \param mt pointer to the top level mapitest structure \return true on success, otherwise false */ _PUBLIC_ bool mapitest_zentyal_1804(struct mapitest *mt) { enum MAPISTATUS retval; mapi_object_t obj_store; mapi_object_t obj_folder; mapi_object_t obj_message; mapi_id_t id_folder; char **username = NULL; struct SPropTagArray *SPropTagArray = NULL; struct PropertyValue_r value; struct PropertyRowSet_r *RowSet = NULL; struct SRowSet *SRowSet = NULL; struct PropertyTagArray_r *flaglist = NULL; mapi_id_t id_msgs[1]; /* Step 1. Logon */ mapi_object_init(&obj_store); retval = OpenMsgStore(mt->session, &obj_store); mapitest_print_retval(mt, "OpenMsgStore"); if (GetLastError() != MAPI_E_SUCCESS) { return false; } /* Step 2. Open Outbox folder */ retval = GetDefaultFolder(&obj_store, &id_folder, olFolderOutbox); mapitest_print_retval(mt, "GetDefaultFolder"); if (GetLastError() != MAPI_E_SUCCESS) { return false; } mapi_object_init(&obj_folder); retval = OpenFolder(&obj_store, id_folder, &obj_folder); mapitest_print_retval(mt, "OpenFolder"); if (GetLastError() != MAPI_E_SUCCESS) { return false; } /* Step 3. Create the message */ mapi_object_init(&obj_message); retval = CreateMessage(&obj_folder, &obj_message); mapitest_print_retval(mt, "CreateMessage"); if (GetLastError() != MAPI_E_SUCCESS) { return false; } /* Step 4. Resolve the recipients and call ModifyRecipients */ SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0xA, PR_ENTRYID, PR_DISPLAY_NAME_UNICODE, PR_OBJECT_TYPE, PR_DISPLAY_TYPE, PR_TRANSMITTABLE_DISPLAY_NAME_UNICODE, PR_EMAIL_ADDRESS_UNICODE, PR_ADDRTYPE_UNICODE, PR_SEND_RICH_INFO, PR_7BIT_DISPLAY_NAME_UNICODE, PR_SMTP_ADDRESS_UNICODE); username = talloc_array(mt->mem_ctx, char *, 2); username[0] = (char *)mt->profile->username; username[1] = NULL; retval = ResolveNames(mapi_object_get_session(&obj_message), (const char **)username, SPropTagArray, &RowSet, &flaglist, MAPI_UNICODE); mapitest_print_retval_clean(mt, "ResolveNames", retval); if (retval != MAPI_E_SUCCESS) { return false; } if (!RowSet) { mapitest_print(mt, "Null RowSet\n"); return false; } if (!RowSet->cRows) { mapitest_print(mt, "No values in RowSet\n"); MAPIFreeBuffer(RowSet); return false; } value.ulPropTag = PR_SEND_INTERNET_ENCODING; value.value.l = 0; PropertyRowSet_propcpy(mt->mem_ctx, RowSet, value); /* Fake multi-value property on RecipientRow */ /* PT_MV_STRING8 */ value.ulPropTag = PR_EMS_AB_PROXY_ADDRESSES; value.value.MVszA.cValues = 2; value.value.MVszA.lppszA = talloc_array(mt->mem_ctx, const char *, value.value.MVszA.cValues); value.value.MVszA.lppszA[0] = "smtp:[email protected]"; value.value.MVszA.lppszA[1] = "X400:c=US;a= ;p=First Organizati;o=Exchange;s=test"; PropertyRowSet_propcpy(mt->mem_ctx, RowSet, value); /* PT_MV_UNICODE - same layout as PT_MV_STRING8 */ value.ulPropTag = PR_EMS_AB_PROXY_ADDRESSES_UNICODE; PropertyRowSet_propcpy(mt->mem_ctx, RowSet, value); /* PT_MV_BINARY */ value.ulPropTag = PidTagUserX509Certificate; value.value.MVbin.cValues = 2; value.value.MVbin.lpbin = talloc_array(mt->mem_ctx, struct Binary_r, value.value.MVbin.cValues); value.value.MVbin.lpbin[0].cb = 9; value.value.MVbin.lpbin[0].lpb = (uint8_t *)"string 1"; value.value.MVbin.lpbin[1].cb = 9; value.value.MVbin.lpbin[1].lpb = (uint8_t *)"string 2"; PropertyRowSet_propcpy(mt->mem_ctx, RowSet, value); SRowSet = talloc_zero(RowSet, struct SRowSet); cast_PropertyRowSet_to_SRowSet(SRowSet, RowSet, SRowSet); SetRecipientType(&(SRowSet->aRow[0]), MAPI_TO); mapitest_print_retval(mt, "SetRecipientType"); retval = ModifyRecipients(&obj_message, SRowSet); mapitest_print_retval_fmt(mt, "ModifyRecipients", "(%s)", "MAPI_TO"); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(RowSet); MAPIFreeBuffer(flaglist); return false; } /* Step 5. Delete the message */ id_msgs[0] = mapi_object_get_id(&obj_message); retval = DeleteMessage(&obj_folder, id_msgs, 1); mapitest_print_retval(mt, "DeleteMessage"); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(RowSet); MAPIFreeBuffer(flaglist); return false; } /* Release */ MAPIFreeBuffer(RowSet); MAPIFreeBuffer(flaglist); mapi_object_release(&obj_message); mapi_object_release(&obj_folder); mapi_object_release(&obj_store); return true; }
CMAPIFolder* CMAPIEx::OpenRootFolder(BOOL bInternal) { return OpenFolder(PR_IPM_SUBTREE_ENTRYID, bInternal); }
int main(int argc, char *argv[]) { enum MAPISTATUS retval; struct mapi_context *mapi_ctx; TALLOC_CTX *mem_ctx; struct mapi_session *session = NULL; mapi_object_t obj_store; mapi_object_t obj_folder; mapi_object_t obj_table; mapi_object_t obj_message; struct mapi_SPropValue_array props_all; struct SRowSet rowset; struct SPropTagArray *SPropTagArray; mapi_id_t id_inbox; mapi_id_t *fid, *mid; char *profname; char *profdb; uint32_t Numerator; uint32_t Denominator; uint32_t i; mem_ctx = talloc_named(NULL, 0, "fetchmail"); /* Initialize MAPI */ profdb = talloc_asprintf(mem_ctx, DEFAULT_PROFDB, getenv("HOME")); retval = MAPIInitialize(&mapi_ctx, profdb); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Find Default Profile */ retval = GetDefaultProfile(mapi_ctx, &profname); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Log on EMSMDB and NSPI */ retval = MapiLogonEx(mapi_ctx, &session, profname, NULL); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Open Message Store */ mapi_object_init(&obj_store); retval = OpenMsgStore(session, &obj_store); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Find Inbox default folder */ retval = GetDefaultFolder(&obj_store, &id_inbox, olFolderInbox); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Open Inbox folder */ mapi_object_init(&obj_folder); retval = OpenFolder(&obj_store, id_inbox, &obj_folder); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Retrieve Inbox content table */ mapi_object_init(&obj_table); retval = GetContentsTable(&obj_folder, &obj_table, 0x0, NULL); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Create the MAPI table view */ SPropTagArray = set_SPropTagArray(mem_ctx, 0x2, PR_FID, PR_MID); retval = SetColumns(&obj_table, SPropTagArray); MAPIFreeBuffer(SPropTagArray); MAPI_RETVAL_IF(retval, retval, mem_ctx); talloc_free(mem_ctx); /* Get current cursor position */ retval = QueryPosition(&obj_table, &Numerator, &Denominator); MAPI_RETVAL_IF(retval, retval, mem_ctx); /* Iterate through rows */ while ((retval = QueryRows(&obj_table, Denominator, TBL_ADVANCE, &rowset)) != -1 && rowset.cRows) { for (i = 0; i < rowset.cRows; i++) { fid = (mapi_id_t *)find_SPropValue_data(&(rowset.aRow[i]), PR_FID); mid = (mapi_id_t *)find_SPropValue_data(&(rowset.aRow[i]), PR_MID); mapi_object_init(&obj_message); retval = OpenMessage(&obj_store, *fid, *mid, &obj_message, 0x0); if (retval != MAPI_E_NOT_FOUND) { retval = GetPropsAll(&obj_message, MAPI_UNICODE, &props_all); mapidump_message(&props_all, NULL, &obj_message); mapi_object_release(&obj_message); } } } /* Release MAPI objects */ mapi_object_release(&obj_table); mapi_object_release(&obj_folder); Logoff(&obj_store); /* Uninitialize MAPI */ MAPIUninitialize(mapi_ctx); return (0); }
static uint32_t _module_fetchmail_run(TALLOC_CTX *mem_ctx, struct mapi_session *session) { enum MAPISTATUS retval; mapi_object_t obj_store; mapi_object_t obj_inbox; mapi_object_t obj_table; mapi_object_t obj_message; mapi_object_t obj_table_attach; mapi_object_t obj_attach; mapi_object_t obj_stream; uint64_t id_inbox = 0; struct SPropTagArray *SPropTagArray; struct SRowSet SRowSet; struct SRowSet SRowSet_attach; uint32_t i, j; uint32_t count; const uint8_t *has_attach; const uint32_t *attach_num; uint16_t read_size; unsigned char buf[MAX_READ_SIZE]; /* Log onto the store */ memset(&obj_store, 0, sizeof(mapi_object_t)); memset(&obj_inbox, 0, sizeof(mapi_object_t)); memset(&obj_table, 0, sizeof(mapi_object_t)); memset(&obj_message, 0, sizeof(mapi_object_t)); memset(&obj_table_attach, 0, sizeof(mapi_object_t)); memset(&obj_attach, 0, sizeof(mapi_object_t)); memset(&obj_stream, 0, sizeof(mapi_object_t)); mapi_object_init(&obj_store); retval = OpenMsgStore(session, &obj_store); if (retval) { mapi_errstr("OpenMsgStore", GetLastError()); return OCSIM_ERROR; } /* Open default receive folder (Inbox) */ retval = GetReceiveFolder(&obj_store, &id_inbox, NULL); if (retval) { mapi_errstr("GetReceiveFolder", GetLastError()); return OCSIM_ERROR; } retval = OpenFolder(&obj_store, id_inbox, &obj_inbox); if (retval) { mapi_errstr("OpenFolder", GetLastError()); return OCSIM_ERROR; } /* Open the contents table and customize the view */ mapi_object_init(&obj_table); retval = GetContentsTable(&obj_inbox, &obj_table, 0, &count); if (retval) { mapi_errstr("GetContentsTable", GetLastError()); return OCSIM_ERROR; } SPropTagArray = set_SPropTagArray(mem_ctx, 0x5, PR_FID, PR_MID, PR_INST_ID, PR_INSTANCE_NUM, PR_SUBJECT); retval = SetColumns(&obj_table, SPropTagArray); MAPIFreeBuffer(SPropTagArray); if (retval) { mapi_errstr("SetColumns", GetLastError()); return OCSIM_ERROR; } /* Retrieve the messages and attachments */ while ((retval = QueryRows(&obj_table, count, TBL_ADVANCE, &SRowSet)) != MAPI_E_NOT_FOUND && SRowSet.cRows) { count -= SRowSet.cRows; for (i = 0; i < SRowSet.cRows; i++) { mapi_object_init(&obj_message); retval = OpenMessage(&obj_store, SRowSet.aRow[i].lpProps[0].value.d, SRowSet.aRow[i].lpProps[0].value.d, &obj_message, 0); if (GetLastError() == MAPI_E_SUCCESS) { struct SPropValue *lpProps; struct SRow aRow; SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_HASATTACH); lpProps = talloc_zero(mem_ctx, struct SPropValue); retval = GetProps(&obj_message, 0, SPropTagArray, &lpProps, &count); MAPIFreeBuffer(SPropTagArray); if (retval) { mapi_errstr("GetProps", GetLastError()); return OCSIM_ERROR; } aRow.ulAdrEntryPad = 0; aRow.cValues = count; aRow.lpProps = lpProps; retval = fetchmail_get_contents(mem_ctx, &obj_message); has_attach = (const uint8_t *) get_SPropValue_SRow_data(&aRow, PR_HASATTACH); if (has_attach && *has_attach) { mapi_object_init(&obj_table_attach); retval = GetAttachmentTable(&obj_message, &obj_table_attach); if (retval == MAPI_E_SUCCESS) { SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_ATTACH_NUM); retval = SetColumns(&obj_table_attach, SPropTagArray); if (retval != MAPI_E_SUCCESS) return retval; MAPIFreeBuffer(SPropTagArray); retval = QueryRows(&obj_table_attach, 0xA, TBL_ADVANCE, &SRowSet_attach); if (retval != MAPI_E_SUCCESS) return retval; for (j = 0; j < SRowSet_attach.cRows; j++) { attach_num = (const uint32_t *) find_SPropValue_data(&(SRowSet_attach.aRow[j]), PR_ATTACH_NUM); mapi_object_init(&obj_attach); retval = OpenAttach(&obj_message, *attach_num, &obj_attach); if (retval == MAPI_E_SUCCESS) { struct SPropValue *lpProps2; uint32_t count2; SPropTagArray = set_SPropTagArray(mem_ctx, 0x3, PR_ATTACH_FILENAME, PR_ATTACH_LONG_FILENAME, PR_ATTACH_SIZE); lpProps2 = talloc_zero(mem_ctx, struct SPropValue); retval = GetProps(&obj_attach, 0, SPropTagArray, &lpProps2, &count2); MAPIFreeBuffer(SPropTagArray); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(lpProps2); return retval; } MAPIFreeBuffer(lpProps2); mapi_object_init(&obj_stream); retval = OpenStream(&obj_attach, PR_ATTACH_DATA_BIN, 0, &obj_stream); if (retval != MAPI_E_SUCCESS) return retval; read_size = 0; do { retval = ReadStream(&obj_stream, buf, MAX_READ_SIZE, &read_size); if (retval != MAPI_E_SUCCESS) break; } while (read_size); mapi_object_release(&obj_stream); mapi_object_release(&obj_attach); } } } } MAPIFreeBuffer(lpProps); } mapi_object_release(&obj_message); }
static enum MAPISTATUS import_directory(TALLOC_CTX *mem_ctx, const struct mbox_data *mdata, mapi_object_t *obj_store, mapi_object_t *obj_parent, const char *base_path) { enum MAPISTATUS retval; DIR *dirp; struct dirent *direntp; mapi_object_t obj_folder; mapi_object_t obj_inbox; mapi_object_t obj_child; mapi_id_t id_folder; char *folder_id; char *olFolderSrc; struct SPropTagArray *SPropTagArray; struct SPropValue *lpProps; uint32_t cValues = 0; struct SRow aRow; DEBUG(5,("[*] Importing directory %s\n", base_path)); /* Open the filesystem folder */ dirp = opendir(base_path); if (!dirp) { DEBUG(0, ("[!] Error opening directory %s: %s (%d)\n", base_path, strerror(errno), errno)); return MAPI_E_NOT_FOUND; // TODO map to proper code } mapi_object_init(&obj_folder); mapi_object_init(&obj_child); mapi_object_init(&obj_inbox); /* I want to get the folder ID from the remote Exchange server and check in the systemfolder database if it matches with something. we can get the remote folder ID from the directory name */ folder_id = import_get_folder_id(base_path); if (!folder_id) { DEBUG(0, ("[!] Error getting folder ID from directory name\n")); return MAPI_E_NOT_FOUND; // TODO map to proper code } if (!obj_parent) { DEBUG(5, ("parent is null\n")); retval = GetDefaultFolder(obj_store, &id_folder, olFolderInbox); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] GetDefaultFolder: %s\n", mapi_get_errstr(GetLastError()))); return retval; } DEBUG(4, ("[*] Opening folder %u\n", olFolderInbox)); retval = OpenFolder(obj_store, id_folder, &obj_inbox); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] OpenFolder: %s\n", mapi_get_errstr(GetLastError()))); return retval; } obj_parent = &obj_inbox; } /* XXX Begin of hack */ #if 0 olFolderSrc = import_is_system_folder(mdata, folder_id); if (!olFolderSrc) { DEBUG(5, ("[*] Not system folder, skip\n")); talloc_free(olFolderSrc); return MAPI_E_SUCCESS; } uint32_t olFolder = atoi(olFolderSrc); talloc_free(olFolderSrc); retval = MAPI_E_SUCCESS; if (olFolder == olFolderContacts) { retval = GetDefaultFolder(obj_store, &id_folder, olFolderContacts); } else if (olFolder == olFolderCalendar) { retval = GetDefaultFolder(obj_store, &id_folder, olFolderCalendar); } else if (olFolder == olFolderTopInformationStore) { retval = GetDefaultFolder(obj_store, &id_folder, olFolderInbox); } if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] GetDefaultFolder: %s\n", mapi_get_errstr(GetLastError()))); return retval; } DEBUG(4, ("Opening folder %u\n", olFolder)); retval = OpenFolder(obj_store, id_folder, &obj_folder); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] OpenFolder: %s\n", mapi_get_errstr(GetLastError()))); return retval; } #endif /* XXX end of hack */ #if 1 olFolderSrc = import_is_system_folder(mdata, folder_id); if (olFolderSrc) { char *folder_name = import_get_folder_name(mdata, folder_id); if (folder_name) { DEBUG(5, ("[*] Origin Folder '%s' mapped to name '%s'\n", folder_id, folder_name)); talloc_free(folder_name); folder_name = NULL; } /* This is a system folder, then I am calling GetDefaultFolder to retrieve the id then I open the folder */ uint32_t olFolder = atoi(olFolderSrc); talloc_free(olFolderSrc); retval = GetDefaultFolder(obj_store, &id_folder, olFolder); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] GetDefaultFolder: %s\n", mapi_get_errstr(GetLastError()))); return retval; } DEBUG(4, ("[*] Opening folder %u\n", olFolder)); retval = OpenFolder(obj_store, id_folder, &obj_folder); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] OpenFolder: %s\n", mapi_get_errstr(GetLastError()))); return retval; } SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PidTagDisplayName); retval = GetProps(&obj_folder, MAPI_UNICODE, SPropTagArray, &lpProps, &cValues); MAPIFreeBuffer(SPropTagArray); if (retval == MAPI_E_SUCCESS) { aRow.cValues = cValues; aRow.lpProps = lpProps; folder_name = (char *) find_SPropValue_data(&aRow, PidTagDisplayName); if (folder_name) { DEBUG(5, ("[*] Destination Folder: '%s'\n", folder_name)); } } } else { /* this is not a system folder, I know what is the root base where need to create it i and open it */ char *folder_name = import_get_folder_name(mdata, folder_id); if (!folder_name) { DEBUG(0, ("[!] Invalid Folder Name\n")); return MAPI_E_INVALID_PARAMETER; } DEBUG(4, ("[*] Creating folder %s\n", folder_name)); retval = CreateFolder(obj_parent, FOLDER_GENERIC, folder_name, NULL, OPEN_IF_EXISTS|MAPI_UNICODE, &obj_folder); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("[!] CreateFolder: %s\n", mapi_get_errstr(GetLastError()))); talloc_free(folder_name); return retval; } talloc_free(folder_name); return MAPI_E_SUCCESS; } #endif /* Import the files and clildren folders */ while ((direntp = readdir(dirp)) != NULL) { if (strcmp(direntp->d_name, ".") == 0) { continue; } if (strcmp(direntp->d_name, "..") == 0) { continue; } char *ext = strrchr(direntp->d_name, '.'); if (!ext) { if (strncasecmp(direntp->d_name, "0x", 2) == 0) { char *child_path = talloc_asprintf(mem_ctx, "%s/%s", base_path, direntp->d_name); retval = import_directory(mem_ctx, mdata, obj_store, &obj_folder, child_path); if (retval != MAPI_E_SUCCESS) { DEBUG(0, ("import_directory failed with %s\n", mapi_get_errstr(GetLastError()))); talloc_free(child_path); return retval; } talloc_free(child_path); } continue; } if (strncasecmp(ext, ".ocpf", 5) == 0) { char *child_path = talloc_asprintf(mem_ctx, "%s/%s", base_path, direntp->d_name); import_ocpf_file(mem_ctx, mdata, obj_store, &obj_folder, child_path); talloc_free(child_path); } } mapi_object_release(&obj_folder); mapi_object_release(&obj_inbox); /* Close directory */ closedir(dirp); return retval; }
LPMAPIFOLDER CExMapi::OpenRootFolder(BOOL bInternal) { return OpenFolder(PR_IPM_SUBTREE_ENTRYID,bInternal); }
VOID DoWM_COMMAND(HWND hwnd, WPARAM wParam, LPARAM lParam) { switch (HIWORD(wParam)) { case EN_CHANGE: if (fileopen) { SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)DirtyMsg); filedirty = TRUE; TimerReset(); } else { SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"File not opened! (save or open new file)."); } break; case BN_CLICKED: if (fileopen) { if (LOWORD(wParam) == BTN_OPENFOLDER) OpenFolder(hwnd); if (LOWORD(wParam) == BTN_REVERT) Revert(hwnd); } else { if (LOWORD(wParam) == BTN_OPENFILE) PromptAndLoadFile(hwnd); } break; } switch (LOWORD(wParam)) { case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case ID_VIEW_HEADERAREA: { HMENU hMenu = GetMenu(hwnd); statusarea = !statusarea; CheckMenuItem(hMenu, ID_VIEW_HEADERAREA, statusarea ? MF_CHECKED : MF_UNCHECKED); FullRedraw(hwnd); break; } case ID_VIEW_STATUSBAR: { HMENU hMenu = GetMenu(hwnd); statusbar = !statusbar; CheckMenuItem(hMenu, ID_VIEW_STATUSBAR, statusbar ? MF_CHECKED : MF_UNCHECKED); ShowWindow(hStatus, statusbar); FullRedraw(hwnd); break; } case ID_VIEW_ORIGINALFILEDATA: { HMENU hMenu = GetMenu(hwnd); OrigDataWindow = !OrigDataWindow; CheckMenuItem(hMenu, ID_VIEW_ORIGINALFILEDATA, statusbar ? MF_CHECKED : MF_UNCHECKED); ShowWindow(hOriginalDataWindow, OrigDataWindow); FullRedraw(hwnd); break; } } }
BOOL CExplorerXPApp::InitInstance() { InOut log (TEXT("CExplorerXPApp::InitInstance")); // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); AfxOleInit(); AfxEnableControlContainer(); InitContextMenuManager(); InitShellManager(); InitThemes(); COleMessageFilter *pfilter = AfxOleGetMessageFilter(); if (pfilter) { pfilter->EnableBusyDialog(FALSE); pfilter->EnableNotRespondingDialog(FALSE); } RegisterShellClipboardFormats (); /*HINSTANCE hInstance = LoadLibrary(_T("Bulgarian.dll")); if( hInstance ) { AfxSetResourceHandle( hInstance ); } */ InitSoftwareLogPath (); gOptions.Load (); gFolderStateMan.Load(); gGroupManager.Load (); dirs.Load(); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; ParseCommandLine(cmdInfo); if ( !m_SingleInstance.Create( IDR_MAINFRAME, cmdInfo) ) return FALSE; // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("ExplorerXP")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_EXPLORTYPE, RUNTIME_CLASS(CExplorerXPDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CExplorerXPView)); AddDocTemplate(pDocTemplate); CMainFrame* pMainFrame = new CMainFrame; { InOut log2 (_T("Mainframe:Load")); // create main MDI Frame window if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; } m_pMainWnd = pMainFrame; // Dispatch commands specified on the command line // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); { InOut log2(_T("MainFrame->FillTree ")); // pMainFrame->FillTree (); } LoadFilters (); dirs.Start (); LoadDefaultTabs(); gShortcutManager.Initialize (); gShortcutManager.LoadAccel(IDR_MAINFRAME); if (!cmdInfo.m_strFileName.IsEmpty ()) { // //AfxMessageBox (cmdInfo.m_strFileName); if (cmdInfo.m_strFileName[cmdInfo.m_strFileName.GetLength() -1] == _T('\"')) cmdInfo.m_strFileName.Delete (cmdInfo.m_strFileName.GetLength() -1); OpenFolder (cmdInfo.m_strFileName); } pMainFrame->RepositionMDIChildsInitial (); return TRUE; }