mail.h 739 Bytes
#pragma once

#include <common.h>
#include <share_msg.pb.h>

struct mail_conf_t 
{
	mail_conf_t();
	std::map<MAIL_ID, std::vector<share_msg::item_t> > mail_map;
	bool load_cfg();
	std::vector<share_msg::item_t>* find(MAIL_ID mail_id);
	uint32_t time_out_sec;
	// 找到最新的版本号对应的邮件ID	 	
	MAIL_ID find_new_version();
};

extern mail_conf_t* g_mail_conf;

class user_t;

struct mail_mgr_t
{
public:
	user_t* user;
	void load(const share_msg::mail_t& r);

	std::map<MAIL_IDX, share_msg::mail_t> mail_map;

	//db, memory, notify
	static uint32_t add_record( user_t* user, USER_ID user_id, MAIL_ID mail_id, ::google::protobuf::Message* msg );
	share_msg::mail_t* find( MAIL_IDX mail_idx );
	//db, memory
	void del(MAIL_IDX mail_idx);
};