Skip to content

Commit

Permalink
bug fix for notifications on 10.15
Browse files Browse the repository at this point in the history
  • Loading branch information
ydkhatri committed Jun 9, 2020
1 parent 09a3b44 commit 71ac0aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 16 additions & 13 deletions plugins/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@
('Title', DataType.TEXT),('SubTitle', DataType.TEXT),('Message', DataType.TEXT), \
('Source', DataType.TEXT)]

def RemoveTabsNewLines(str):
return str.replace("\t", " ").replace("\r", " ").replace("\n", "")
def RemoveTabsNewLines(obj):
if isinstance(obj, str):
return obj.replace("\t", " ").replace("\r", " ").replace("\n", "")
elif isinstance(obj, list):
if len(obj) > 0:
item = str(obj[0])
return item.replace("\t", " ").replace("\r", " ").replace("\n", "")
else:
log.error('Unknown type found : ' + str(type(obj)))

def ProcessNotificationDb(inputPath, output_params):
log.info ("Processing file " + inputPath)
Expand Down Expand Up @@ -114,7 +121,7 @@ def Parse_ver_17_Db(conn, inputPath, user, timezone):
title = RemoveTabsNewLines(req.get('titl', ''))
subtitle = RemoveTabsNewLines(req.get('subt', ''))
message = RemoveTabsNewLines(req.get('body', ''))
except KeyError as ex: log.debug('Error reading field req - ' + str(ex))
except (KeyError, AttributeError) as ex: log.debug('Error reading field req - ' + str(ex))
try:
log.debug('Unknown field orig = {}'.format(plist['orig']))
except (KeyError, ValueError): pass
Expand Down Expand Up @@ -233,16 +240,14 @@ def Plugin_Start(mac_info):
darwin_user_folders = user.DARWIN_USER_DIR.split(',')
for darwin_user_dir in darwin_user_folders:
db_path = darwin_user_dir + '/com.apple.notificationcenter/db/db'
if not mac_info.IsValidFilePath(db_path): continue
else:
ProcessNotificationDb_Wrapper(db_path, mac_info, user.user_name)
if mac_info.IsValidFilePath(db_path):
mac_info.ExportFile(db_path, __Plugin_Name, user.user_name + '_')
#For High Sierra db2 is present. If upgraded, both might be present
db_path = darwin_user_dir + '/com.apple.notificationcenter/db2/db'
if not mac_info.IsValidFilePath(db_path): continue
else:
ProcessNotificationDb_Wrapper(db_path, mac_info, user.user_name)
#For High Sierra db2 is present. If upgraded, both might be present
db_path = darwin_user_dir + '/com.apple.notificationcenter/db2/db'
if mac_info.IsValidFilePath(db_path):
mac_info.ExportFile(db_path, __Plugin_Name, user.user_name + '_')
ProcessNotificationDb_Wrapper(db_path, mac_info, user.user_name)
WriteOutput(mac_info.output_params)

## Standalone Plugin call
Expand All @@ -258,6 +263,4 @@ def Plugin_Start_Standalone(input_files_list, output_params):

##
if __name__ == '__main__':
print("This plugin is a part of a framework and does not run independently on its own!")


print("This plugin is a part of a framework and does not run independently on its own!")
2 changes: 2 additions & 0 deletions plugins/recentitems.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ def PrintAll(recent_items, output_params, source_path):
name = item.Name
if name.startswith('file://'):
name = name[7:]
if name == '' and url != '':
name = os.path.basename(url)
data_list.append( [ str(item.Type), name, url, item.Info, item.User, item.Source ] )

WriteList("Recent item information", "RecentItems", data_list, recent_info, output_params, source_path)
Expand Down

0 comments on commit 71ac0aa

Please sign in to comment.