diff --git a/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h b/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h index 9d1abdbe..f4c6eb43 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h +++ b/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h @@ -106,6 +106,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; NSMutableDictionary *m_dictGroupContacts; } - (id)GetAllGroups; +- (id)GetGroupMemberContact:(id)arg1; @end @interface WCContactData : NSObject @@ -143,6 +144,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (BOOL)isChatRoomMessage; - (NSString *)groupChatSenderDisplayName; - (id)getRealMessageContent; +- (id)getChatRoomUsrName; - (BOOL)isSendFromSelf; - (BOOL)isCustomEmojiMsg; - (BOOL)isImgMsg; @@ -291,6 +293,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @interface MMAvatarService : NSObject - (NSString *)avatarCachePath; +- (void)avatarImageWithContact:(id)arg1 completion:(void (^)(NSImage *image))arg2; @end @interface NSString (MD5) diff --git a/Other/Products/Debug/WeChatPlugin.framework/Modules/module.modulemap b/Other/Products/Debug/WeChatPlugin.framework/Modules/module.modulemap new file mode 100644 index 00000000..1e785538 --- /dev/null +++ b/Other/Products/Debug/WeChatPlugin.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module WeChatPlugin { + umbrella header "WeChatPlugin.h" + + export * + module * { export * } +} diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h index 9d1abdbe..f4c6eb43 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h @@ -106,6 +106,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; NSMutableDictionary *m_dictGroupContacts; } - (id)GetAllGroups; +- (id)GetGroupMemberContact:(id)arg1; @end @interface WCContactData : NSObject @@ -143,6 +144,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (BOOL)isChatRoomMessage; - (NSString *)groupChatSenderDisplayName; - (id)getRealMessageContent; +- (id)getChatRoomUsrName; - (BOOL)isSendFromSelf; - (BOOL)isCustomEmojiMsg; - (BOOL)isImgMsg; @@ -291,6 +293,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @interface MMAvatarService : NSObject - (NSString *)avatarCachePath; +- (void)avatarImageWithContact:(id)arg1 completion:(void (^)(NSImage *image))arg2; @end @interface NSString (MD5) diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Modules/module.modulemap b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Modules/module.modulemap new file mode 100644 index 00000000..1e785538 --- /dev/null +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module WeChatPlugin { + umbrella header "WeChatPlugin.h" + + export * + module * { export * } +} diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin index 6d170e69..c09e0b1a 100755 Binary files a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin and b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin differ diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h index 9d1abdbe..f4c6eb43 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h @@ -106,6 +106,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; NSMutableDictionary *m_dictGroupContacts; } - (id)GetAllGroups; +- (id)GetGroupMemberContact:(id)arg1; @end @interface WCContactData : NSObject @@ -143,6 +144,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (BOOL)isChatRoomMessage; - (NSString *)groupChatSenderDisplayName; - (id)getRealMessageContent; +- (id)getChatRoomUsrName; - (BOOL)isSendFromSelf; - (BOOL)isCustomEmojiMsg; - (BOOL)isImgMsg; @@ -291,6 +293,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @interface MMAvatarService : NSObject - (NSString *)avatarCachePath; +- (void)avatarImageWithContact:(id)arg1 completion:(void (^)(NSImage *image))arg2; @end @interface NSString (MD5) diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Modules/module.modulemap b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Modules/module.modulemap new file mode 100644 index 00000000..1e785538 --- /dev/null +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module WeChatPlugin { + umbrella header "WeChatPlugin.h" + + export * + module * { export * } +} diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin index 6d170e69..c09e0b1a 100755 Binary files a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin and b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin differ diff --git a/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin b/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin index 6d170e69..c09e0b1a 100755 Binary files a/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin and b/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin differ diff --git a/Other/Uninstall.sh b/Other/Uninstall.sh index c899cb6f..39c786f3 100755 --- a/Other/Uninstall.sh +++ b/Other/Uninstall.sh @@ -24,7 +24,13 @@ then rm "$app_executable_path" rm -rf "$framework_path" mv "$app_executable_backup_path" "$app_executable_path" -echo "\n\t卸载成功" + +if [ -f "$app_executable_backup_path" ] + echo "卸载失败,请到 /Applications/WeChat.app/Contents/MacOS 路径,删除 WeChatPlugin.framework、WeChat 两个文件文件,并将 WeChat_backup 重命名为 WeChat" +then + echo "\n\t卸载成功" +fi + else echo "\n\t未发现微信小助手" fi diff --git a/WeChatPlugin/Sources/Config/TKWeChatPluginConfig.h b/WeChatPlugin/Sources/Config/TKWeChatPluginConfig.h index d1be9494..fd3b6cee 100644 --- a/WeChatPlugin/Sources/Config/TKWeChatPluginConfig.h +++ b/WeChatPlugin/Sources/Config/TKWeChatPluginConfig.h @@ -18,12 +18,12 @@ @property (nonatomic, assign) BOOL autoLoginEnable; /**< 是否自动登录 */ @property (nonatomic, assign) BOOL onTop; /**< 是否要置顶微信 */ @property (nonatomic, assign) BOOL multipleSelectionEnable; /**< 是否要进行多选 */ -@property (nonatomic, assign) BOOL forbidCheckVersion; /**< 禁止检测版本 */ -@property (nonatomic, copy) NSMutableArray *autoReplyModels; /**< 自动回复的数组 */ -@property (nonatomic, copy) NSMutableArray *remoteControlModels; /**< 远程控制的数组 */ -@property (nonatomic, copy) NSMutableArray *ignoreSessionModels; /**< 聊天置底的数组 */ -@property (nonatomic, copy) NSMutableArray *selectSessions; /**< 已经选中的会话 */ -@property (nonatomic, copy) NSMutableSet *revokeMsgSet; /**< 撤回的消息集合 */ +@property (nonatomic, assign) BOOL forbidCheckVersion; /**< 禁止检测版本 */ +@property (nonatomic, strong) NSMutableArray *autoReplyModels; /**< 自动回复的数组 */ +@property (nonatomic, strong) NSMutableArray *remoteControlModels; /**< 远程控制的数组 */ +@property (nonatomic, strong) NSMutableArray *ignoreSessionModels; /**< 聊天置底的数组 */ +@property (nonatomic, strong) NSMutableArray *selectSessions; /**< 已经选中的会话 */ +@property (nonatomic, strong) NSMutableSet *revokeMsgSet; /**< 撤回的消息集合 */ @property (nonatomic, copy) NSString *currentUserName; /**< 当前用户的id */ @property (nonatomic, copy, readonly) NSDictionary *localInfoPlist; @property (nonatomic, copy, readonly) NSDictionary *romoteInfoPlist; diff --git a/WeChatPlugin/Sources/Managers/TKAssistantMenuManager.m b/WeChatPlugin/Sources/Managers/TKAssistantMenuManager.m index 61606e65..6b3879d0 100644 --- a/WeChatPlugin/Sources/Managers/TKAssistantMenuManager.m +++ b/WeChatPlugin/Sources/Managers/TKAssistantMenuManager.m @@ -37,16 +37,18 @@ - (void)initAssistantMenuItems { target:self keyEquivalent:@"t" state:[[TKWeChatPluginConfig sharedConfig] preventRevokeEnable]]; - // 防撤回自己 - NSMenuItem *preventSelfRevokeItem = [NSMenuItem menuItemWithTitle:TKLocalizedString(@"assistant.menu.revokeSelf") - action:@selector(onPreventSelfRevoke:) - target:self - keyEquivalent:@"" - state:[[TKWeChatPluginConfig sharedConfig] preventSelfRevokeEnable]]; - - NSMenu *subPreventMenu = [[NSMenu alloc] initWithTitle:TKLocalizedString(@"assistant.menu.revoke")]; - [subPreventMenu addItems:@[preventSelfRevokeItem]]; - preventRevokeItem.submenu = subPreventMenu; + if ([[TKWeChatPluginConfig sharedConfig] preventRevokeEnable]) { + // 防撤回自己 + NSMenuItem *preventSelfRevokeItem = [NSMenuItem menuItemWithTitle:TKLocalizedString(@"assistant.menu.revokeSelf") + action:@selector(onPreventSelfRevoke:) + target:self + keyEquivalent:@"" + state:[[TKWeChatPluginConfig sharedConfig] preventSelfRevokeEnable]]; + + NSMenu *subPreventMenu = [[NSMenu alloc] initWithTitle:TKLocalizedString(@"assistant.menu.revoke")]; + [subPreventMenu addItems:@[preventSelfRevokeItem]]; + preventRevokeItem.submenu = subPreventMenu; + } // 自动回复 NSMenuItem *autoReplyItem = [NSMenuItem menuItemWithTitle:TKLocalizedString(@"assistant.menu.autoReply") @@ -164,6 +166,21 @@ - (void)changePluginMenuItemWithIndex:(NSInteger)index state:(NSControlStateValu - (void)onPreventRevoke:(NSMenuItem *)item { item.state = !item.state; [[TKWeChatPluginConfig sharedConfig] setPreventRevokeEnable:item.state]; + if (item.state) { + // 防撤回自己 + NSMenuItem *preventSelfRevokeItem = [NSMenuItem menuItemWithTitle:TKLocalizedString(@"assistant.menu.revokeSelf") + action:@selector(onPreventSelfRevoke:) + target:self + keyEquivalent:@"" + state:[[TKWeChatPluginConfig sharedConfig] preventSelfRevokeEnable]]; + + NSMenu *subPreventMenu = [[NSMenu alloc] initWithTitle:TKLocalizedString(@"assistant.menu.revoke")]; + [subPreventMenu addItems:@[preventSelfRevokeItem]]; + item.submenu = subPreventMenu; + } else { + item.submenu = nil; + } + } /** diff --git a/WeChatPlugin/Sources/Managers/TKCacheManager.h b/WeChatPlugin/Sources/Managers/TKCacheManager.h index 7784a007..000f9176 100644 --- a/WeChatPlugin/Sources/Managers/TKCacheManager.h +++ b/WeChatPlugin/Sources/Managers/TKCacheManager.h @@ -15,5 +15,6 @@ - (BOOL)fileExistsWithName:(NSString *)fileName; - (NSString *)filePathWithName:(NSString *)fileName; - (NSString *)cacheEmotionMessage:(MessageData *)emotionMsg; +- (NSString *)cacheAvatarWithContact:(WCContactData *)contact; @end diff --git a/WeChatPlugin/Sources/Managers/TKCacheManager.m b/WeChatPlugin/Sources/Managers/TKCacheManager.m index c4a57dc4..16bc13d4 100644 --- a/WeChatPlugin/Sources/Managers/TKCacheManager.m +++ b/WeChatPlugin/Sources/Managers/TKCacheManager.m @@ -12,6 +12,7 @@ @interface TKCacheManager () @property (nonatomic, copy) NSString *cacheDirectory; @property (nonatomic, strong) NSMutableSet *emotionSet; +@property (nonatomic, strong) NSMutableSet *avatarSet; @end @implementation TKCacheManager @@ -42,6 +43,7 @@ - (instancetype)init } self.emotionSet = [NSMutableSet set]; + self.avatarSet = [NSMutableSet set]; } return self; } @@ -113,4 +115,30 @@ - (void)emoticonDownloadFinished:(EmoticonMsgInfo *)msgInfo { }]; } +- (NSString *)cacheAvatarWithContact:(WCContactData *)contact { + NSString *headImgUrl = contact.m_nsHeadImgUrl; + if (headImgUrl.length == 0) return @""; + + NSString *imgPath = @""; + if ([headImgUrl respondsToSelector:@selector(md5String)]) { + NSString *imgMd5Str = [headImgUrl performSelector:@selector(md5String)]; + MMAvatarService *avatarService = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MMAvatarService")]; + + if ([avatarService avatarCachePath] && imgMd5Str) { + imgPath = [NSString stringWithFormat:@"%@%@",[avatarService avatarCachePath], imgMd5Str]; + NSFileManager *fileMgr = [NSFileManager defaultManager]; + if (![fileMgr fileExistsAtPath:imgPath] && ![self.avatarSet containsObject:imgPath]) { + [self.avatarSet addObject:imgPath]; + [avatarService avatarImageWithContact:contact completion:^(NSImage *image) { + NSData *imageData = [image TIFFRepresentation]; + [imageData writeToFile:imgPath atomically:YES]; + [self.avatarSet removeObject:imgPath]; + }]; + } + + } + } + return imgPath ?: @""; + +} @end diff --git a/WeChatPlugin/Sources/Managers/TKWebServerManager.m b/WeChatPlugin/Sources/Managers/TKWebServerManager.m index d924b198..ef9646bb 100644 --- a/WeChatPlugin/Sources/Managers/TKWebServerManager.m +++ b/WeChatPlugin/Sources/Managers/TKWebServerManager.m @@ -145,7 +145,7 @@ - (void)addHandleForSearchUserChatLog { WCContactData *toUserContact = [sessionMgr getContact:userId]; NSString *wechatId = [toUserContact getContactDisplayUsrName]; NSString *title = [weakSelf getUserNameWithContactData:toUserContact showOriginName:YES]; - NSString *imgPath = [weakSelf cacheAvatarPathFromHeadImgUrl:toUserContact.m_nsHeadImgUrl]; + NSString *imgPath = [[TKCacheManager shareManager] cacheAvatarWithContact:toUserContact]; NSDictionary *toUserContactDict = @{@"title": [NSString stringWithFormat:@"To: %@", title], @"subTitle": chatLogList.count > 0 ? TKLocalizedString(@"assistant.search.chatlog") : @"", @"icon": imgPath ?: @"", @@ -241,17 +241,23 @@ - (NSDictionary *)dictFromGroupSearchResult:(MMComplexGroupContactSearchResult * NSString *contactName; if(contact.contact.m_nsRemark && ![contact.contact.m_nsRemark isEqualToString:@""]) { contactName = contact.contact.m_nsRemark; + if (contact.fieldType != 1) { + contactName = [NSString stringWithFormat:@"%@(%@)", contactName, matchStr]; + } } else { contactName = contact.contact.m_nsNickName; + if (contact.fieldType != 3) { + contactName = [NSString stringWithFormat:@"%@(%@)", contactName, matchStr]; + } } - [subTitleArray addObject:[NSString stringWithFormat:@"%@(%@)", contactName, matchStr]]; + [subTitleArray addObject:contactName]; }]; } NSString *subTitle = @""; if (subTitleArray.count > 0) { - subTitle = [NSString stringWithFormat:@"%@: %@",TKLocalizedString(@"assistant.search.member"),[subTitleArray componentsJoinedByString:@", "]]; + subTitle = [NSString stringWithFormat:@"%@%@",TKLocalizedString(@"assistant.search.member"),[subTitleArray componentsJoinedByString:@", "]]; } - NSString *imgPath = [self cacheAvatarPathFromHeadImgUrl:groupContact.m_nsHeadImgUrl]; + NSString *imgPath = [[TKCacheManager shareManager] cacheAvatarWithContact:groupContact]; NSString *wechatId = [groupContact getContactDisplayUsrName]; return @{@"title": [NSString stringWithFormat:@"%@%@", TKLocalizedString(@"assistant.search.group"), groupContact.getGroupDisplayName], @@ -311,7 +317,7 @@ - (NSDictionary *)dictFromContactSearchResult:(MMComplexContactSearchResult *)re } NSString *subTitle =[self matchWithContactResult:result]; - NSString *imgPath = [self cacheAvatarPathFromHeadImgUrl:contact.m_nsHeadImgUrl]; + NSString *imgPath = [[TKCacheManager shareManager] cacheAvatarWithContact:contact]; NSString *wechatId = [contact getContactDisplayUsrName]; return @{@"title": title, @@ -331,7 +337,7 @@ - (NSDictionary *)dictFromSessionInfo:(MMSessionInfo *)sessionInfo { NSString *title = [self getUserNameWithContactData:contact showOriginName:YES]; NSString *msgContent = [[TKMessageManager shareManager] getMessageContentWithData:msgData]; - NSString *imgPath = [self cacheAvatarPathFromHeadImgUrl:contact.m_nsHeadImgUrl]; + NSString *imgPath = [[TKCacheManager shareManager] cacheAvatarWithContact:contact]; NSString *wechatId = [contact getContactDisplayUsrName]; return @{@"title": title, @@ -419,7 +425,16 @@ - (NSDictionary *)dictFromMessageData:(MessageData *)msgData { } NSString *subTitle = [self getDateStringWithTimeStr:msgData.msgCreateTime]; - NSString *imgPath = [self cacheAvatarPathFromHeadImgUrl:msgContact.m_nsHeadImgUrl]; + + NSString *imgPath; + if ([msgContact isGroupChat]) { + GroupStorage *contactStorage = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("GroupStorage")]; + WCContactData *fromContact = [contactStorage GetGroupMemberContact:[msgData getChatRoomUsrName]]; + imgPath = [[TKCacheManager shareManager] cacheAvatarWithContact:fromContact]; + } else { + imgPath = [[TKCacheManager shareManager] cacheAvatarWithContact:msgContact]; + } + if (!msgContact.isGroupChat) { subTitle = [NSString stringWithFormat:@"from: %@ %@",[self getUserNameWithContactData:msgContact showOriginName:NO], subTitle]; } @@ -462,21 +477,6 @@ - (NSString *)getDateStringWithTimeStr:(NSTimeInterval)time{ return @""; } -// 获取本地图片缓存路径 -- (NSString *)cacheAvatarPathFromHeadImgUrl:(NSString *)imgUrl { - if (imgUrl.length == 0) return @""; - - NSString *imgPath = @""; - if ([imgUrl respondsToSelector:@selector(md5String)]) { - NSString *imgMd5Str = [imgUrl performSelector:@selector(md5String)]; - MMAvatarService *avatarService = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MMAvatarService")]; - if ([avatarService avatarCachePath] && imgMd5Str) { - imgPath = [NSString stringWithFormat:@"%@%@",[avatarService avatarCachePath], imgMd5Str]; - } - } - return imgPath ?: @""; -} - - (NSString *)getUserNameWithContactData:(WCContactData *)contact showOriginName:(BOOL)showOriginName { if (!contact) return @""; diff --git a/WeChatPlugin/WeChatPlugin.h b/WeChatPlugin/WeChatPlugin.h index 9d1abdbe..f4c6eb43 100644 --- a/WeChatPlugin/WeChatPlugin.h +++ b/WeChatPlugin/WeChatPlugin.h @@ -106,6 +106,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; NSMutableDictionary *m_dictGroupContacts; } - (id)GetAllGroups; +- (id)GetGroupMemberContact:(id)arg1; @end @interface WCContactData : NSObject @@ -143,6 +144,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (BOOL)isChatRoomMessage; - (NSString *)groupChatSenderDisplayName; - (id)getRealMessageContent; +- (id)getChatRoomUsrName; - (BOOL)isSendFromSelf; - (BOOL)isCustomEmojiMsg; - (BOOL)isImgMsg; @@ -291,6 +293,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @interface MMAvatarService : NSObject - (NSString *)avatarCachePath; +- (void)avatarImageWithContact:(id)arg1 completion:(void (^)(NSImage *image))arg2; @end @interface NSString (MD5)